Run a controller function whenever a view is opened/shown

后端 未结 9 1589
滥情空心
滥情空心 2020-12-01 02:28

I\'m building an app with angular+ionic that uses a classic three-button menu at the bottom with three ion-tabs in it. When a user clicks a tab, that template opens through

9条回答
  •  清歌不尽
    2020-12-01 03:04

    By default, your controllers were cache and that is why your controller only fired once. To turn off caching for a certain controller you have to modify your .config(..).state and set the cache option to false. eg :

      .state('myApp', {
        cache: false,
        url: "/form",
        views: {
          'menuContent': {
            templateUrl: "templates/form.html",
            controller: 'formCtrl'
          }
        }
      })
    

    for further reading please visit http://ionicframework.com/docs/api/directive/ionNavView/

提交回复
热议问题