源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Angularjs CURD 详解及实例代码

  • 时间:2022-07-25 11:57 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Angularjs CURD 详解及实例代码
[b]Angularjs CURD [/b] [b]前言[/b]        基于一个手机端的项目使用了angularjs,硬着头皮去用,有很多的疑问还需要一一去验证,刚开始总是感觉找不到北,总是感觉有很多概念,而且似乎ng既夹杂MVC又夹杂MVVM的思想, 忙里偷闲敲了个简单的CURD demo。 当然顺着这个demo还可以延伸很多知识点,比如: 带分页查询、连接后台数据库、调用WebApi、分层使用Servcice、Factory。 [b]效果图[/b]  [img]http://files.jb51.net/file_images/article/201609/2016914113730397.png?2016814113750[/img] [img]http://files.jb51.net/file_images/article/201609/2016914113803796.png?2016814113816[/img] [img]http://files.jb51.net/file_images/article/201609/2016914113825436.png?2016814113838[/img]
<script type="text/javascript">

    var app=angular.module('myApp',[]);

    app.controller('empCtrl',function($scope){

      $scope.emparr=[];

       

      //添加

      $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='';

      //编辑

      $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;

      }

      //修改

      $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.desg='';

      }

       

      $scope.del=function(id){

        $scope.emparr.splice(id,1);

      }

    });

  </script> 


  


以上就是对AngularJS CURD 的资料整理,后续继续补充相关资料,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部