angular.js - When angular jumps from route A to route B for the first time, the controller of route B will be initialized. When it jumps to route B for the second time, the controller of route B will not be initialized.
世界只因有你
世界只因有你 2017-05-15 17:03:27
0
3
743

When angular jumps from route A to route B for the first time, the controller of route B will be initialized; when it jumps to route B for the second time, if the parameters in the route change, the controller of route B will be initialized again. Initialization is performed; if the parameters in the route do not change, the controller of route B will not be initialized again. How can we make the route initialize its controller every time it jumps?

`//The routing configuration is as follows:

    .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