0

尝试从我的应用程序中的一种状态转到另一种状态时出现错误。

我在一个索引文件中定义了我的所有状态。

index.js

var MyModule = angular.module('myApp.ui.moduleTest', [
  'ui.router'
])
.config(function($stateProvider, modalStateProvider){
  $stateProvider

    .state('myApp.dashboard.appArea.moduleTest',
      modalStateProvider.create({
        animation: true,
        name: 'myApp.dashboard.appArea.moduleTest',
        url: 'apps/moduleTest',
        controllerAs: 'moduleTestCtrl',
        controller: 'ModuleTestCtrl',
        windowClass: 'semi-modal semi-modal--huge',
        templateUrl: function() {
          return 'app/ui/apps/moduleTest/widget.html';
        },
        resolve: {
          //Some function to retrieve data
        }
      })
    )
    .state('myApp.dashboard.appArea.moduleTest.wizards',
      modalStateProvider.create({
        animation: true,
        name: 'myApp.dashboard.appArea.moduleTest.wizards',
        url: 'apps/moduleTest/runWizard',
        controllerAs: 'moduleTestWizardCtrl',
        controller: 'ModuleTestWizardCtrl',
        templateUrl: function(){
          return 'app/ui/apps/moduleTest/wizard.html';
        }
        // resolve: {
        //
        // }
      })
    )
})

当我处于状态“myApp.dashboard.appArea.moduleTest”Fron ModuleTestCtrl 我试图进入状态“myApp.dashboard.appArea.moduleTest.wizards”但我收到错误“无法解析状态”。如何在我的控制器中导入此配置模块以导航到该状态?

/*jslint node: true */
'use strict';

var angular = require('angular');

function ModuleTestCtrl($uibModalInstance, Api, diagnosticsRaw,  myService, $state) {

  this.$uibModalInstance = $uibModalInstance;
  this.Api = Api;
  this.dataRaw = diagnosticsRaw;

  this.parserData = function(indexes) {
      //Some app logic irrelevant
  }

  myService.setPropertyToRun(this.dataRaw);
  myService.setIsPropertyToRun(true);

$state.go('myApp.dashboard.appArea.moduleTest.wizards'); //THIS IS WHERE I HAVE MY PROBLEM

  };
}

ModuleTestCtrl.$inject = ['$uibModalInstance', 'Api', 'diagnosticsRaw', 'myService', '$state']; module.exports = ModuleTestCtrl;

4

1 回答 1

1

您是否在 angular.config 中描述了所有父状态myApp.dashboard.appArea.moduleTestmyApp.dashboard.appArea.moduleTest.wizards如果没有,这可能是问题所在。

示例:
wizards 是 moduleTest 的子代,它是 appArea 的子代,appArea 的子代是仪表板的子代,仪表板是 myApp 的子代,你明白了。您首先需要声明所有这些父状态,即使它们可能不做任何事情。

有关 ui-state 的更多信息,请访问:
https ://github.com/angular-ui/ui-router/wiki/Nested-States-and-Nested-Views

于 2016-08-02T12:11:10.013 回答