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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -