Angularjs CURD
Preface
A mobile-based project uses angularjs and uses it with a lot of questions. There are many questions that need to be verified one by one. At the beginning, I always feel that I can't find it, and I always feel that there are many concepts. It seems that I'm mixed with both MVC and MVVM ideas. I took a break from my busy schedule and knocked on a simple CURD demo. Of course, following this demo, you can extend many knowledge points, such as: paging query, connecting to the background database, calling WebApi, using Servcice in layered, and Factory.
Reproduction diagram
<script type="text/javascript"> var app=angular.module('myApp',[]); app.controller('empCtrl',function($scope){ $scope.emparr=[]; //Add $scope.btnclk=function(){ $scope.emparr.push({'arr_id':$scope.id,'arr_name':$scope.name,'arr_desg':$scope.desg}); $scope.id=''; $scope.name=''; $scope.desg=''; } var key=''; //Edit $scope.edit=function(emp,indx){ key=indx; console.log(indx); console.log(emp); $scope.id=emp.arr_id; $scope.name=emp.arr_name; $scope.desg=emp.arr_desg; } //Modify $scope.btnupd=function(id,name,desg){ $scope.emparr[key].arr_id=id; $scope.emparr[key].arr_name=name; $scope.emparr[key].arr_desg=desg; $scope.id=''; $scope.name=''; $scope.emparr[key].arr_desg=desg; $scope.id=''; $scope.name=''; $scope.desg=''; } $scope.del=function(id){ $scope.emparr.splice(id,1); } }); </script>The above is the information sorting out AngularJS CURD. We will continue to add relevant information in the future. Thank you for your support to this site!