angularjs multiple controllers on one page

后端 未结 5 952
甜味超标
甜味超标 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:41

    Every time you use ng-controller, you make a new instance of said controller, with it's own scope. If you set subCCtrl on the body tag (or a new parent), and remove it from the two divs it is currently on, it works for me.

    Other solutions you might want to look in to are by keeping "hideThisBox" on the root scope, broadcasting an event when clicking on save or by keeping it in a service.

提交回复
热议问题