照例先看效果
:
<! Doctype html> <html lang = "en" ng-app = "scapp"> <éad> <meta charset = "utf-8"> <title> </ title> <script src = "lib / angular.min.js" type = "text / javascript"> </script> </-head> <body ng-control ng-repeat = "Con dans le contenu"> <input type = "text" ng-model = "con.num1" ng-change = "changeNum1 (con)" /> <input type = "text" ng-model = "num2" value = "Con.Num2" /> <entrée type = "text" ng-model = "con.total" ng-change = "changetotal (con)" </div> </ body> <script> var app = angular.module ("SCApp", []) .Controller ("ScController", ["$ Scope", fonction ($ Scope) {$ Scope.Num2 = 2; $ Scope.content = [{num1: 1, num2: 3, total: 3,}, {{num1: 2, num2: 3,},}, {{num1: 2, 2, 3, 3,},},}, {} Num1: 1, num2: 6, 6,}]; $ scope.changem1 = fonction (con) {con.total = con.num1 * con.num2;};总结
其实方法非常简单 , 只需要在每个ng-repeat中传入具体的每一个数据分组就可以实现 , 例如本例子中的ng-change="changeNum1(con)"<code/>这样就实现了单独的小的数据作用域的控制。
以上就是这篇文章的全部内容 , 希望对大家学习或使用 Angularjs 能有所帮助 , 如果有疑问可以留言交流。