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++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -