2
การผูก ng-model ภายใน ng-repeat loop ใน AngularJS
ฉันกำลังพยายามจัดการกับปัญหาของขอบเขตภายในการวนซ้ำ ng-repeat - ฉันได้เรียกดูคำถามหลายข้อ แต่ยังไม่สามารถทำให้รหัสของฉันทำงานได้ รหัสคอนโทรลเลอร์: function Ctrl($scope) { $scope.lines = [{text: 'res1'}, {text:'res2'}]; } ดู: <div ng-app> <div ng-controller="Ctrl"> <div ng-repeat="line in lines"> <div class="preview">{{text}}{{$index}}</div> </div> <div ng-repeat="line in lines"> <-- typing here should auto update it's preview above --> <input value="{{line.text}}" ng-model="text{{$index}}"/> <!-- many other fields here that …