使用angularJS接收json数据并进行数据的显示
发布时间:2020-12-17 17:55:42 所属栏目:安全 来源:网络整理
导读:1.引入 JS script type ="text/javascript" src ="../plugins/angularjs/angular.min.js" / script ? 2.指定模块和控制器 ? body class ="hold-transition skin-red sidebar-mini" ng-app ="pinyougou" ng-controller ="brandController" ng-init = findAll(
1.引入JS <script type="text/javascript" src="../plugins/angularjs/angular.min.js"></script> ? 2.指定模块和控制器 ? <body class="hold-transition skin-red sidebar-mini" ng-app="pinyougou" ng-controller="brandController" ng-init = findAll()> ? 3.编写js代码 <script type="text/javascript"> var app= angular.module(‘pinyougou‘,[]);//定义模块 app.controller(‘brandController‘,function($scope,$http){ //读取列表 $scope.findAll = function(){ $http.get(‘../brand/findAll.do‘).success( function(response){ $scope.list = response; } ); } }); </script> ? 4.循环数据表格 <tbody> <tr ng-repeat="entity in list"> <td><input type="checkbox" ></td> <td>{{entity.id}}</td> <td>{{entity.name}}</td> <td>{{entity.firstChar}}</td> <td class="text-center"> <button type="button" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#editModal" >修改</button> </td> </tr> </tbody> ? 5.结果显示 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |