Angular UI 不同州的路由器相同的 TemplateUrls 问题
Angular UI Router Same TemplateUrls issue for different States
我将 AngularJS 与 $stateProvider 一起使用,其中 2 个不同的状态指向相同的模板网址。代码片段在下面
$stateProvider
.state('training', {
url: "/training",
templateUrl: "partials/training.html",
controller: function($scope, $http, $state, $uibModal){
console.log("Main Training State");
$http.get('/api/training').success(function (response){
var data = response;
$scope.courses=data.courses;
}).error(function(err,status){
console.log(err);
});
$scope.openReadMoreModal = function (course) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'readmoremodal.html',
controller: 'ModalInstanceCtrl',
resolve: {
modalObject: course
}
});
};
}
})
.state('mytraining', {
url: "training/me",
templateUrl: "partials/training.html",
controller: function($scope, $http, $state, $uibModal){
console.log("get My Events in the training html");
$http.get('/api/training/myevents').success(function (response){
console.log("response :"+ response);
$scope.courses = response.courses;
}).error(function(err,status){
console.log(err);
});
$scope.openReadMoreModal = function (course) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'readmoremodal.html',
controller: 'ModalInstanceCtrl',
resolve: {
modalObject: course
}
});
};
}
})
问题是控制不会流向 mytraining 状态。请告诉我这是什么问题?
应该是:
url: "/training/me",
和不
url: "training/me",
处于我的训练状态
试试这个:
.state('training', {
url: "/training",
templateUrl: "partials/training.html",
/* ... some config ... */
.state('training.me', {
url: "/me",
templateUrl: "partials/training.html",
我将 AngularJS 与 $stateProvider 一起使用,其中 2 个不同的状态指向相同的模板网址。代码片段在下面
$stateProvider
.state('training', {
url: "/training",
templateUrl: "partials/training.html",
controller: function($scope, $http, $state, $uibModal){
console.log("Main Training State");
$http.get('/api/training').success(function (response){
var data = response;
$scope.courses=data.courses;
}).error(function(err,status){
console.log(err);
});
$scope.openReadMoreModal = function (course) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'readmoremodal.html',
controller: 'ModalInstanceCtrl',
resolve: {
modalObject: course
}
});
};
}
})
.state('mytraining', {
url: "training/me",
templateUrl: "partials/training.html",
controller: function($scope, $http, $state, $uibModal){
console.log("get My Events in the training html");
$http.get('/api/training/myevents').success(function (response){
console.log("response :"+ response);
$scope.courses = response.courses;
}).error(function(err,status){
console.log(err);
});
$scope.openReadMoreModal = function (course) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'readmoremodal.html',
controller: 'ModalInstanceCtrl',
resolve: {
modalObject: course
}
});
};
}
})
问题是控制不会流向 mytraining 状态。请告诉我这是什么问题?
应该是:
url: "/training/me",
和不
url: "training/me",
处于我的训练状态
试试这个:
.state('training', {
url: "/training",
templateUrl: "partials/training.html",
/* ... some config ... */
.state('training.me', {
url: "/me",
templateUrl: "partials/training.html",