last day (15 days later) » 

3:47 AM
0
A: How to call the parent boolean with function to child in angular

abney317You'll have to pass the value to your child component list.component.html <nz-switch [(ngModel)]="toggleUnit" nzCheckedChildren="&deg;F" nzUnCheckedChildren="&deg;C" (ngModelChange)="onSwitchChange()"></nz-switch> <div class="weather"> <app-weather [toggleUnit]="toggleUnit"></app-weather> </div

 
ABC
but sir, when I click the button its doesn't change.
I have nz-switch which is <nz-switch [(ngModel)]="toggleUnit" nzCheckedChildren="&deg;F" nzUnCheckedChildren="&deg;C" (ngModelChange)="onSwitchChange()"></nz-switch>
 
Updated with change emitter
 
ABC
I got an error Expected 0 type arguments, but got 1 <boolean>
 
Ah I see what you're trying. Give me a moment :)
 
ABC
fixed sir. how'bout when you check in childComponent if its changed
 
3:47 AM
What I original had should work. Changes in the parent component should automatically be seen in the child. If you want to listen for the changes you can use ngOnChanges in the child
hey
 
ABC
hello sir
 
problems still?
 
ABC
how to apply it sir? sorry I'm just new in angular..
cause I saw a sample
Angular 5 ngOnChanges fires only once in child component
How to check in ngOnChanges() if its already change?
wait sir. I'll check
 
The ngOnChanges should be firing any time you change that parent variable
 
ABC
ohh.. ok sir. wait
thanks
 
3:57 AM
it worked?
 
ABC
yes.
how'bout the
@Output() toggleUnitChange = new EventEmitter<boolean>();
do i need to remove it?
 
Shouldn't need it
 

last day (15 days later) »