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 tree
  • ngzone.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

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -