所以我试图让UI-Router的解析方法工作,但我一直收到这个错误,但我没有成功解决这个问题。 Error: No template configuration specified for 'resolve@root'
这是我的stateProvider的定义:
$stateProvider
.state('root', {
abstract: true,
views: {
'header@': {
template: '<div>Header</div>',
},
'footer@': {
template: '<div>Footer</div>',
}
}
})
.state('root.home', {
views: {
'home@': {
url: '/',
templateUrl: 'src/survey/survey.template.html',
controller: 'homeController'
},
resolve: {
communityId: ['backendFactoryService', function (backendFactoryService) {
backendFactoryService....then(function (res) {
return res;
})
}],
brandingId: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}],
community: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}],
branding: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}]
}
}
})
在我的home.controller.js
(function() {
'use strict'
angular.module('someModule')
.controller('homeController', homeController)
homeController.$inject = [
'$scope',
'branding',
'brandingId',
'community',
'communityId'
];
function homeController(
$scope,
branding,
brandingId,
community,
communityId
) {
$scope.community = community;
$scope.branding = branding;
$scope.brandingId = brandingId;
$scope.communityId = communityId;
}
})();
显然,我有一个控制器和解析块的templateUrl。我尝试为我的根状态添加一个空的<div ui-view=""></div>
或<ui-view></ui-view>
,但没有。
我找不到我得到的错误的答案,希望有人可以帮助我。
编辑:
我还尝试在template: ' '
州添加root
。没有不同。
答案 0 :(得分:0)
错误是因为
resolve: {
communityId: ['backendFactoryService', function (backendFactoryService) {
backendFactoryService....then(function (res) {
return res;
})
}],
brandingId: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}],
community: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}],
branding: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}]
}
因为它认为resolve
是视图名称,它正在检查模板,控制器等。
所以将状态配置代码更改为
.state('root.home', {
resolve: {
communityId: ['backendFactoryService', function (backendFactoryService) {
backendFactoryService....then(function (res) {
return res;
})
}],
brandingId: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}],
community: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}],
branding: ['backendFactoryService', function (backendFactoryService) {
// do stuff
})
}]
},
views: {
'home@': {
url: '/',
templateUrl: 'src/survey/survey.template.html',
controller: 'homeController',
}
}
})