我正在使用ui-router 0.2.10。我的应用程序有两个不同的模板,index.html & index2.html。我创建了一个抽象状态,并且我在两个状态中都引用了这两个索引。问题是我可以访问第一个路由,但是当我尝试访问下一个路由时,它只是默认第一个路由。抽象模板位于同一个文件夹中。ui路由器路由使用不同模板的2种不同状态
缺少什么我在这里?
.config(["$stateProvider", "$urlRouterProvider", function(sp, urp) {
urp.otherwise("/index1");
sp.state("index1", {
abstract:true,
url: "/index1",
templateUrl: "index.html"
});
sp.state("index1.id", {
url: "/id",
template: "views/partials/index.partial.html",
controller: function($scope,$state){
$state.go('index1.id');
}
});
sp.state("index2", {
abstract:true,
url: "/index2",
templateUrl: "index2.html"
});
sp.state("index2.id", {
url: "/id",
template: "views/partials/index2.partial.html",
controller: function($scope,$state){
$state.go('index2.id');
}
});
}])
该代码似乎可以互换使用'template'和'templateUrl';然而,'template'应该包含原始HTML,而'templateURL'则指向一个文件。 –