当我们添加更多项目时,重复不重要

时间:2015-10-13 08:58:07

标签: javascript angularjs wcf model-view-controller using

我正在使用ng重复来显示用户员工的详细信息。当我们添加新项目时,ng重复不会更新。

Controller.js代码:

app.controller('CRUD_AngularJs_RESTController', function ($scope, CRUD_AngularJs_RESTService) {

    $scope.OperType = 1;  
    //1 Mean New Entry  

    GetAllRecords();  
    //To Get All Records  
    function GetAllRecords() {  
        var promiseGet = CRUD_AngularJs_RESTService.getAllStudent();  
        promiseGet.then(function (pl) { $scope.Emp_Vichra = pl.data, $scope.$apply() },
              function (errorPl) {  
                  $log.error('Some Error in Getting Records.', errorPl);  
                  $scope.$apply();
              });  
    }  

    //To Clear all input controls.  
    function ClearModels() {  
        $scope.OperType = 1;  
        $scope.Project = "";  
        $scope.Task = "";  
        $scope.Date = "";  
        $scope.Hour = "";          
    }  

    //To Create new record and Edit an existing Record.  
    $scope.save = function () {  
        var Student = {  
            Project: $scope.Project,  
            Task: $scope.Task,  
            Date: $scope.Date,  
            Hour: $scope.Hour             
        };  
        if ($scope.OperType === 1) {  
            var promisePost = CRUD_AngularJs_RESTService.post(Student);            
            promisePost.then(function (pl) {
                $scope.Message = "New Project Saved Successfuly";
                $scope.Project = pl.data.Project;                
                GetAllRecords();        
                ClearModels();
                $scope.Action = "Add";
                //$scope.$apply();
            }, function (err) {  
                console.log("Some error Occured" + err);  
            });  
        } else {  
            //Edit the record      
            debugger;  
            Student.StudentID = $scope.StudentID;  
            var promisePut = CRUD_AngularJs_RESTService.put($scope.StudentID, Student);            
            promisePut.then(function (pl) {  
                $scope.Message = "Student Updated Successfuly";  
                GetAllRecords();  
                ClearModels();  
            }, function (err) {  
                console.log("Some Error Occured." + err);  
            });  
        }  
    };     
});

0 个答案:

没有答案