How to prevent controller reloading when using ng-switch

情到浓时终转凉″ 提交于 2019-12-04 10:23:39

There is no way of preventing the existing ngSwitch from re-instantiating controllers and re-creating a new scope. As noted in the documentation this directive is creating a new scope and actually creates / destroys corresponding DOM elements.

If you goal is to preserve state just put it in one of the parent scopes, check this jsFiddle: http://jsfiddle.net/FBHjZ/2/

An alternative approach is to use a service for the shared model.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!