how to triger ngOnChanges programmatically

181 views
Skip to first unread message

gede sutarsa

unread,
Jan 23, 2016, 8:54:51 PM1/23/16
to AngularJS
Dear , 

i'm new on angular 2 , and currently learning on directives . Based on this example https://angular.io/resources/live-examples/attribute-directives/ts/plnkr.html
in my understanding, on   file app/app.component.html
when i click on radio button for example green, it will set variable : color to "green". 
but when i programmatically replace variable color for with example : "red", 
why the ngOnChanges not called as it called with --> 
 (click)="color='cyan'"
 
is there is some way to change the class property and fire change notification 

thx before
best regards, 
 

Sander Elias

unread,
Jan 28, 2016, 2:12:15 AM1/28/16
to AngularJS
Hi Gede,

ngOnChanges is an event handler. The DOM fires that event on the moment it detects user intervention. If you are under program control, and you need the function to run, you can simply call it.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages