Я использую AngularJS с $ stateProvider с двумя разными состояниями, указывающими на одни и те же шаблоны. Снимок кода ниже
$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",