angular.js - angularjs改变路由时控制器每次都执行两次?
怪我咯
怪我咯 2017-05-15 16:55:09
0
9
592

我是angularjs初学者,最近练习过程中遇到一个问题,改变路由后,路由指向的控制器每次都执行两次,有没有遇到过这样问题的朋友,看是哪里出了问题。

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(9)
某草草

A rough estimate is that you added ng-controller="controller you defined" to your html code

習慣沉默

I have just used ng’s routing. In fact, in the routing configuration, we configured a controller for different templates. At this time, we no longer need to write it in the template

ng-controller
世界只因有你

Looking at your html code, I guess you initialized the control twice somewhere.

曾经蜡笔没有小新

Has the poster found the cause of this problem now? I have also encountered it. Please give me some advice.

PHPzhong

<p class="dv_contain" ng-controller="controller"> This happened many times

曾经蜡笔没有小新

I defined the controller once in $stateProvider, and then defined it again in html using ng-controller and controller as, and encountered the same situation. This can be solved by using controllerAs directly in $stateProvider.

PHPzhong

Have your problem been solved? I also encountered this problem. I have only defined the controller in $stateProvider. I only need to switch it a few times and execute it several times. Each time it corresponds to a different $scope

小葫芦

Excuse me, if I don’t add ng-controller to my page, or should I use ng-click to execute it twice, it will jump twice? If I use ng-click, it will jump once

仅有的幸福

ng-view is written twice, just remove one and it will be fine

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!