2016-07-26 12 views
0

$ stateProviderでAngularJSを使用していて、2つの異なる州が同じテンプレートを指しています。コードスニペットは、問題がコントロールがmytraining状態に流れないということである角度UIルーター異なる州の同じTemplateUrl問題

$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 
        } 
       }); 
      }; 
     } 
    }) 

を下回っています。問題は何ですか?

+0

を:URL: "/トレーニング/私 "、mytraining状態のため –

+0

@ RahulAroraありがとう..あなたは私の日を救った。それは働く.. –

+0

私は答えとしてそれを書くでしょう。あなたがそれを受け入れることができれば。 –

答えて

1

それは次のようになります。

url: "/training/me", 

ませ

url: "training/me", 

状態に

0

をmytrainingで、このしてみてください:URLはすべきではない

.state('training', { 
    url: "/training", 
    templateUrl: "partials/training.html", 

/* ... some config ... */ 

.state('training.me', { 
     url: "/me", 
     templateUrl: "partials/training.html", 
関連する問題