angularjs-指令ng-disable,ng-repeat
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了angularjs-指令ng-disable,ng-repeat相关的知识,希望对你有一定的参考价值。
#ng-disable 禁用标签 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="js/angular.min.js"></script> </head> <body> <div ng-app="app" ng-controller="ctrl"> 同意:<input type="checkbox" ng-model="status" ng-init="status=0"/><br /> <input type="button" value="登陆" ng-disabled="!status"/> </ul> </div> <script type="text/javascript"> var m=angular.module(‘app‘,[]); m.controller(‘ctrl‘,[‘$scope‘,function($scope){ }]); </script> </body> </html>
#ng-repeat 标签,遍历对象 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="js/angular.min.js"></script> </head> <body> <div ng-app="app" ng-controller="ctrl"> <ul> <li ng-repeat="d in odata"> my name is {{d.name}},i am {{d.age}} </li> </ul> </div> <script type="text/javascript"> var m=angular.module(‘app‘,[]); m.controller(‘ctrl‘,[‘$scope‘,function($scope){ $scope.odata=[ {‘name‘:‘cxiong‘,‘age‘:29}, {‘name‘:‘xmzhang‘,‘age‘:29} ] }]); </script> </body> </html> #ng-repeat 标签,遍历数组 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="js/angular.min.js"></script> </head> <body> <div ng-app="app" ng-controller="ctrl"> <ul> <!--报错:数组中存在重复元素,track by $index--> <li ng-repeat="d in odata track by $index"> my name is {{d}} </li> </ul> </div> <script type="text/javascript"> var m=angular.module(‘app‘,[]); m.controller(‘ctrl‘,[‘$scope‘,function($scope){ $scope.odata=[‘xmzhang‘,‘cxiong‘,‘fjwu‘,‘cxiong‘] }]); </script> </body> </html>
以上是关于angularjs-指令ng-disable,ng-repeat的主要内容,如果未能解决你的问题,请参考以下文章