Angularjs watch for change in parent scope

前端 未结 5 1732
甜味超标
甜味超标 2020-12-24 05:32

I\'m writing a directive and I need to watch the parent scope for a change. Not sure if I\'m doing this the preferred way, but its not working with the following code:

5条回答
  •  情歌与酒
    2020-12-24 05:41

    You should have the data property on your child scope, scopes use prototypal inheritance between parent and child scopes.

    Also, the first argument the $watch method expects is an expression or a function to evaluate and not a value from a variable., So you should send that instead.

提交回复
热议问题