search

Home  >  Q&A  >  body text

angular.js - angular第一次从A路由跳转到B路由时,B路由的控制器会初始化,第二次跳转到B路由时,B路由的控制器不初始化

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>
世界只因有你世界只因有你2744 days ago705

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:05:27

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

    reply
    0
  • 迷茫

    迷茫2017-05-15 17:05:27

    Add $watch

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-15 17:05:27

    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.

    reply
    0
  • Cancelreply