2016-03-04 44 views
0

This My ng-repeat Code。這是主菜單。包括早餐,午餐等。我想動態地讓這個國家。使用ui-sref獲取動態狀態

下面的代碼是HTML

<li class="mega-menu" ng-repeat="gethead in details" > 
<a style="padding-left:10px;padding-right:10px;" class="level-top" href="" 
ui-sref="menu.breakfast({_id:gethead._id})">{{gethead.ctgname}}</a></li> 

其我的腳本中的app.config

$stateProvider.state("menu.breakfast", {url:"/breakfast/:_id", 
templateUrl:"partials/breakfast/breakfastveg.html",controller:"MyCtrl", 
     resolve:{ 
       breakfast :["$http","$stateParams",function($http,$stateParams){ 
           var url="menu/" + $stateParams._id; 
           return $http.get(url).then(function(res){ 
           return res.data;}) 
          }] 
          }}) 

它不工作....請幫我...

回答

0

你可以做這與ng點擊:

...ng-click="goToState(gethead)"> 

並在控制器中:

... 
$scope.goToState = function(gethead) { 
    $state.go(gethead._id); 
} 
... 
+0

對不起老兄。不工作...任何方式感謝您的快速回復@Boris Parnikel – SrinivasAppQube

+0

對不起,我誤以爲。如果gethead._id是一個國家的名稱,那麼你應該做$ state.go(gethead._id) –

+0

非常感謝你鮑里斯帕米克爾它的工作現在。 – SrinivasAppQube