Access directive's isolate scope from within transcluded content

后端 未结 3 1787
太阳男子
太阳男子 2021-02-13 02:35

I\'m not sure if this is actually possible, but I\'m essentially wanting a reverse of the \'&\' isolate scope in AngularJS. Here is a Plunkr to demonstrate.

Basicall

3条回答
  •  长发绾君心
    2021-02-13 03:13

    Here is a plunk that solves your current problem. I am not sure what you are attempting to do. But as far as I know, there is no way of calling something in the isolate scope from an external scope. Ofcourse, you could setup a two way bound variable between the isolate scope and the external scope, change the variable in the external scope and $watch for it on the isolate scope ( this will work like an eventing mechanism )... That is one way of doing what you are attempting to do.. if you insist on it.

    Alternatively, there is a mechanism to call a function on the external scope from the isolate scope. Its kind of like a callback.

    See this http://plnkr.co/edit/5MT4vo9qXtV6nQikfEiH?p=preview

提交回复
热议问题