ng-repeat="v in arr track by $index"
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><title>Document</title></head><body ng-app="myApp"><!--ng-init:初始化数据ng-init="person={name:'小明'}"--><div ng-app="myApp" ng-controller="myController"><input type="text" ng-model="iptValue"><input type="button" ng-click="clickFn()" value="按钮"><ul><li ng-repeat="v in arr track by $index">{{v}}</li></ul></div></body><script type="text/javascript" src="angular.min.js"></script><script type="text/javascript">// [] ---> 依赖var app = angular.module("myApp",[]);// $scope作用域:作用域范围myControllerapp.controller("myController",function($scope){$scope.arr = ["111","222"];$scope.clickFn = function(){var v = $scope.iptValue;$scope.arr.push(v);$scope.iptValue = "";}});</script></html>
1.现象