AngularJS Custom Directive Two Way Binding

前端 未结 5 1090
甜味超标
甜味超标 2020-12-29 08:17

If I have an AngularJS directive without a template and I want it to set a property on the current scope, what is the best way to do it?

For example, a directive tha

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 09:12

    Why is an isolate scope overkill? its pretty useful for exactly this kind of thing:

      scope: {
         "twoway": "=" // two way binding
      },
    

    This is a pretty idiomatic angular solution to this problem, so this is what I'd stick with.

提交回复
热议问题