1

When i click on view Button from department list Data not showing on view template. i am not using any service. please help me someone.........

my source code is given below ......

My Angularjs Controller:

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

DeptApp.controller('DeptCtrl', function ($scope, $routeParams, $location, $route) {

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

});

Here is My List Template: ng-click="DeptView(Dept)"

Here is My View Template: Dept Name: ng-model="Dept1.DEPT_NAME"

4
  • instead of jQuery.ajax try $http Commented Jun 3, 2015 at 5:48
  • Are you getting any errors in the console? $scope.$apply() could probably be throwing an error Commented Jun 3, 2015 at 7:37
  • Yes . Error: [$rootScope:inprog] $apply already in progress but if i comment // $scope.$apply() dont show error but not show any data to view template. Commented Jun 3, 2015 at 8:48
  • how to pass object with angularjs routing .when('/Edit/:Id', { templateUrl: baseSiteUrlPath + 'Templates/Hrm_dept/Edit.html', controller: 'DeptCtrl' }) Commented Jun 3, 2015 at 8:50

1 Answer 1

0

Try the following (don't forget to declare $http in your controller)

$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.
      });
Sign up to request clarification or add additional context in comments.

1 Comment

List is showing but when i click on view buttion from list of dept and fire this function then Dept value not showing to view template .. $scope.DeptView = function (Dept) { console.log(Dept); $scope.Dept1 = angular.copy(Dept); var id = 1; var earl = '/Edit/' + id; $location.path(earl); $scope.$apply(); };

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.