Angular / Ionic - controller only runs once

前端 未结 5 1577
無奈伤痛
無奈伤痛 2021-02-20 18:57

I\'m starting out with Angular through the Ionic Framework but I am failing to understand why the controller only runs once i.e. I change state, the controller runs, change to a

5条回答
  •  无人共我
    2021-02-20 19:19

    Building on @brandyshea's answer, I would like to add if you want to specify no caching in one area/controller/state, and take advantage of the caching in other areas, you can simply use the cache parameter in your $stateProvider for that state.

    Disable cache within state provider

    $stateProvider.state('myState', {
      cache: false,
      url : '/myUrl',
      templateUrl : 'my-template.html'
    })
    

    Alternatively, you can use one of the other methods too:

    Disable cache with an attribute

    
    ...
    
    

    Disable cache globally The $ionicConfigProvider can be used to set the maximum allowable views which can be cached, but this can also be use to disable all caching by setting it to 0.

    $ionicConfigProvider.views.maxCache(0);
    

    References: http://ionicframework.com/docs/api/directive/ionNavView/ and http://ionicframework.com/docs/api/directive/ionView/

提交回复
热议问题