2016-09-23 137 views
0

我是新的angularjs我有一個索引頁面,當用戶點擊一個特定的錨標記頁面時,有一些數據帶有錨點標記頁面重定向到列表頁面並顯示數據但ngRoute不工作,也沒有得到查詢字符串值。當我錯了
這是我的索引頁angularjs ngroute無法正常工作

<div class="all_cat" ng-repeat="state in statelist"> 
    <h2>{{state.Statename}}</h2> 
    <div class="cat-col-4" ng-repeat="citylist in state.city"> 
     <ul> 
      <li><i class="fa fa-caret-right"></i><a href="/Job/JobList/{{citylist.ID}}">{{citylist.cityname}} </a>({{citylist.jobcount}})</li> 
     </ul> 
    </div> 
    <div class="clear"></div> 
</div> 

,這是我的js

var app = angular.module('angularTable', ['ngSanitize', 'ui.select', 'angularTrix', 'ngRoute']); 
app.config(function($routeProvider) { 
    debugger; 
    $routeProvider 
     .when('/JobList:ID', { 
      templateUrl: 'job/JobList.cshtml', 
      controller: 'joblist' 
     }) 

}); 


app.controller('joblist', function($scope, $routeParams) { 
    debugger; 
    $scope.message = 'Clicked person name from home page should be display here'; 
    $scope.person = $routeParams.ID; 
}); 

我不是下架我哪裏錯了

+1

你可能想'/招賢納才/:ID',而不是'/招賢納才:ID' – taguenizy

+0

同樣的問題$ routeParams.ID未定義 –

+0

您是否嘗試過'$路線。 current.params'或類似的東西? – taguenizy

回答

0

屁股braja LAL Mahanty告訴你可能想/ JobList /:ID而不是/ JobList:ID。 所以,你必須設置狀態:

$routeProvider 
.when('/JobList/:ID', { 
     templateUrl: 'job/JobList.cshtml', 
     controller: 'joblist' 
    }) 
});