Can I use one controller updating two views in AngularJS?

后端 未结 1 1162
挽巷
挽巷 2021-01-07 14:14

Is it possible, to have two views bound to one controller, so that both views get updated no matter where the data was changed (view1, view2 or in the model)? It should work

相关标签:
1条回答
  • 2021-01-07 14:39

    There's no reason you can't do this, but the same object has to be in the scope of both controllers. See http://plnkr.co/edit/ILzGCs9AYiPTETE92KTm?p=preview

    In the original example, each scope has it's own object, and so each is operating on their own object. If both scopes share the same object, then each is operating on the same object, and thus changes in one scope is reflected in the other.

    0 讨论(0)
提交回复
热议问题