2015-06-03 61 views
1

當我點擊視圖按鈕從部門列表數據不顯示在視圖模板上。我沒有使用任何服務。 請幫助我的人.........下面Angularjs與數據路由

我的源代碼中給出......

我Angularjs控制器:

.when('/Edit/:Id', { 
     templateUrl: baseSiteUrlPath + 'Templates/Hrm_dept/Edit.html', 
     controller: 'DeptCtrl' 
    }) 

DeptApp.controller(」 DeptCtrl」,函數($範圍,$ routeParams,$位置,$路徑){

$scope.Dept = {}; 
$scope.Dept1 = {}; 
$scope.DeptList = []; 
$scope.DeptList1 = []; 
$scope.ishide = true; 

$scope.DeptView = function (Dept) { 
    console.log(Dept); 
    **$scope.Dept1 = angular.copy(Dept);** 
    var id = 1; 
    **var earl = '/Edit/' + id;** 
    $location.path(earl); 
    $scope.$apply(); 
}; 

}); 

這裏是我的清單模板: NG點擊=「DeptView(德PT)」

這裏是我的視圖模板: 部門名稱:NG-模型= 「Dept1.DEPT_NAME」

+0

而不是jQuery.ajax嘗試$ http –

+0

您是否在控制檯中發現任何錯誤? '$ scope。$ apply()'可能會拋出一個錯誤 –

+0

是的。錯誤:[$ rootScope:inprog] $ apply已經在進行,但是如果我評論// $ scope。$ apply()不顯示錯誤,但不顯示任何數據來查看模板。 –

回答

0

試試下面的(不要忘了在你的控制器聲明$http

$http.get('/HRM_DEPT/GetAllDepartment'). 
     success(function(data, status, headers, config) { 
     $scope.DeptList = data; 
    // this callback will be called asynchronously 
     // when the response is available 
     }). 
     error(function(data, status, headers, config) { 
     // called asynchronously if an error occurs 
     // or server returns response with an error status. 
     }); 
+0

列表是示出了但是當我點擊部門列表中的視圖buttion並激活此功能,然後部門值不顯示查看模板。 $ scope.Dept1 = angular.copy(Dept); var id = 1; var earl ='/ Edit /'+ id; $ location.path(earl); $ scope。$ apply(); }; –