angular - Triggering Angular2 change detection manually -
i'm writing angular 2 component has property mode(): string
. able set property programmatically not in response event. problem in absence of browser event, template binding {{mode}}
doesn't update. there way trigger change detection manually?
try 1 of these:
applicationref.tick()
- similar angular 1's$rootscope.$digest()
-- i.e., check full component treengzone.run(callback)
- similar$rootscope.$apply(callback)
-- i.e., evaluate callback function inside angular 2 zone. think, i'm not sure, ends checking full component tree after executing callback function.changedetectorref.detectchanges()
- similar$scope.$digest()
-- i.e., check component , children
you can inject applicationref
, ngzone
, or changedetectorref
component.
Comments
Post a Comment