angularjs multiple controllers on one page

后端 未结 5 961
甜味超标
甜味超标 2021-02-12 15:50

I have a page with multiple controllers, one of the controller is being used in 2 different divs within the same page. I am not sure if it is a scope issue or I just miss someth

5条回答
  •  花落未央
    2021-02-12 16:14

    Same controller, but declared twice. therefor - two scopes.
    Normally the solution is to move the ng-controller declaration one dom level higher (in your case, to the body element. once only), and have it only once. Otherwise, look into angular services.

    see updated plunkr: http://plnkr.co/edit/pWnx2mdMeOeH33LUeTGm?p=preview

提交回复
热议问题