无法转换到状态,获取未定义状态的错误

时间:2017-05-03 10:01:02

标签: angularjs angular-ui-router

我目前在调用后的主页面上 http://localhost:8199/#/iceberg-ui

我有一个名为 iceberg.reconcreate 的州,定义如下。

但是当我尝试在单击按钮时调用 $ state.go('iceberg.reconcreate')时,我收到状态未定义的错误。

  

angular-ui-router.js:982未捕获错误:没有这样的状态未定义   Object.go上的Object.transitionTo(angular-ui-router.js:982)   HTMLAnchorElement上的(angular-ui-router.js:973)。   (angular-ui-router.js:1383)在HTMLAnchorElement.dispatch上   (jquery.js:4641)在HTMLAnchorElement.elemData.handle(jquery.js:4309)

ROUTING

    routingSetup.$inject = ['$stateProvider', '$urlRouterProvider'];
    function routingSetup($stateProvider, $urlRouterProvider) {

    $urlRouterProvider.otherwise("/iceberg-ui");

    $stateProvider
        .state('iceberg', {
            url: "/iceberg-ui",
            templateUrl: "app/iceberg/iceberg.view.html",
            controller: 'IcebergController as icebergCtrl'
        })
        .state('iceberg.reconlist', {
            templateUrl: "app/iceberg/recon/list/recon.list.view.html",
            controller: 'ReconListController as reconListCtrl'
        })
        .state('iceberg.reconcreate', {
            templateUrl: "app/iceberg/recon/create/recon.create.view.html",
            controller: 'ReconCreateController as reconCreateCtrl'
        })
        .state('iceberg.recondetails', {
            templateUrl: "app/iceberg/recon/details/recon.details.view.html",
            controller: 'ReconDetailsController as reconDetailsCtrl'
        })
}

控制器

(function() {
'use strict';

var myApp = angular.module('iceberg.recon');
myApp.controller('ReconListController', ReconListController);

ReconListController.$inject = ['ReconListService', '$state'];

function ReconListController(ReconListService, $state) {
    var vm = this;

    function getReconciliationList() {
        return {
            load: function(loadOptions) {
                var reconList = ReconListService.getReconciliationList();
                return {
                    data: reconList,
                    totalCount: reconList.length
                };
            },
            update: function(key, values) {
                console.log("calling the UPDATE GRID");
                //Do Nothing, this method is required else the framework throws an error
            }
        };
    }



    vm.createNewRecon = {
        text: "Create New Reconciliation",
        icon: "plus",
        type: "success",
        height: "45px",
        onClick: function(e) {
            $state.go('iceberg.reconcreate');
        }
    };

}
}());

更新 - 更新了控制器详细信息

1 个答案:

答案 0 :(得分:0)

对不起那些人,这是我的疏忽。我有一个ui-sref定义了错误的名称和所有这一切,而我认为它被称为onclick事件。我的坏,为此道歉。