如何解决角度ui路由

时间:2016-09-21 13:49:57

标签: angularjs

这是我的angularjs代码。我创建了不同的路线,但我无法解决我的contract.dashboard路线。如果我删除路由对象,它工作正常,但当我试图从我的服务重新获得一些东西时,它不起作用。

 (function() {
        'use strict';

        angular
            .module('app.contracts')
            .run(appRun);

        var _base = {
            // Contract Base Contractor
            contract: {
                controllerAs: 'c',
                controller: ['$scope', '$state', 'ContractModel', function($scope, $state, ContractModel){
                    'ngInject';
                    var that = this;
                    $scope.$watch(function(){ return $state.current.data.mode; }, function() { that.mode = $state.current.data.mode; });
                    that.contract = new ContractModel();
                }]
            }
        };

        /* @ngInject */
        function appRun(routerHelper) {
            routerHelper.configureStates(getStates());
        }

        function getStates() {
            return [
                {
                    state: 'contract',
                    config: angular.extend({
                        abstract: true,
                        template: '<contract-manager><ui-view/></<contract-manager>',
                        url: '/contract'
                    }, _base.contract)
                },
                {
                    state: 'contract.new',
                    config: angular.extend({
                        url: '/new',
                        template: '<contract-editor mode="c.mode" contract="c.contract"></<contract-editor>',
                        title: 'Contract Editor',
                        data: {
                            mode: 'new'
                        }
                    }, _base.contract)
                },
                {
                    state: 'contract.dashboard',
                    config: angular.extend({
                        url: '',
                        template: '<contract-dashboard></contract-dashboard>',
                        title: 'Contract Dashboard',
                        data: {
                          mode:'dashboard'
                        },
                        resolve: {
                           stubs: function(stubs){
                             return stubs.service.registerGetCustomers();
                           }
                        }
                    }, _base.contract)
                }
            ];
        }
    })();

0 个答案:

没有答案