AngularJS / ui-router: $state.go does not work inside ng-click

后端 未结 3 1669
星月不相逢
星月不相逢 2020-12-31 05:33

I have a view where I have the following code:


T

3条回答
  •  一向
    一向 (楼主)
    2020-12-31 06:04

    According to https://github.com/angular-ui/ui-router/wiki/Quick-Reference#note-about-using-state-within-a-template you can add it to $rootScope, so it will be available in all the scopes and hence all the templates, by

    angular.module("myApp").run(function ($rootScope, $state, $stateParams) {
      $rootScope.$state = $state;
      $rootScope.$stateParams = $stateParams;
    });
    

提交回复
热议问题