javascript - Directive talks to controller but cannot call functions residing in controller -


i have directive needs call functions main controller everytime try reference function inside directive nothing happens because it's undefined. when access value instance $scope.someprop desired response not when call function.

anyone else who's faced issue? suggestions?

few things:

  • your controller exposes startchange function on scope, need call on scope, i.e. 'scope.startchange()' within directive , not 'startchange()'
  • your confirmation directive uses isolate scope great if know youre doing, in essence cutting off parents scope on trying call function

you got 3 options in case

  1. use scope $emit/$broadcast share state
  2. use isolate scope , '&' syntax execute expression in context of parent scope -- example http://plnkr.co/edit/8uedpos6ie5qtfc8e08h?p=preview
  3. not use isolate scope , execute startchange function on scope of directive same scope of controller -- example: http://plnkr.co/edit/h1t2qnol7wgng0eprlmc?p=preview

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -