angular.js - angular第一次从A路由跳转到B路由时,B路由的控制器会初始化,第二次跳转到B路由时,B路由的控制器不初始化
世界只因有你
世界只因有你 2017-05-15 17:03:27
0
3
636

angular第一次从A路由跳转到B路由时,B路由的控制器会初始化;第二次跳转到B路由时,如果路由中的参数变化了,则B路由的控制器再次进行初始化;如果路由中的参数没有变化,则B路由的控制器不会再次进行初始化。怎么样才能让,路由每次跳转都初始化一次它的控制器呢?

`//路由配置如下所示:

    .state('calendarUpdate',{
        url:"/calendarUpdate?itemOid",
        templateUrl:"templates/calendar/calendarUpdate.html",
        controller:"CalendarUpdateCtrl"
    })`
//跳转方式如下:
<a ui-sref=calendarUpdate({itemOid: itemOid})>跳转</a>
世界只因有你
世界只因有你

reply all(3)
Ty80

Have you used ionic? Ionic’s cache mode does not reload.

迷茫

Add $watch

给我你的怀抱

You made a mistake. Regardless of whether the parameters in the route have changed or not, the controller will be initialized. Follow the official angular tutorial:

For memory usage and performance considerations, the controller will only be instantiated when needed, and will be destroyed when no longer needed. This means that every time you switch routes or reload a view, the current controller will be cleared by AngularJS.

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!