使用此代码:
<!doctype html> <html lang="en" ng-app="app"> <head> <Meta charset="UTF-8"> <title>ngTest</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.js"></script> <script> angular .module('app',[]) .controller('Main',['$scope',function($s) { $s.data = { level1: { level2: { elements: [{ name: 'item1' },{ name: 'item2' },{ name: 'item3' },{ name: 'item4' }] } } }; }]); </script> </head> <body ng-controller="Main"> <div ng-repeat="item in data.level1.level2.elements"> <input type="file" ng-model="item.name"> </div> <pre>{{data}}</pre> </body>
会引发这个错误:
Error: An attempt was made to use an object that is not,or is no longer,usable.
一旦将type =“file”更改为type =“text”,错误就会消失.知道怎么解决这个问题吗?我将编写一个指令,即使在输入上也会监听更改,上传给定文件并将其值分配给绑定模型.但我这个错误阻止了我这样做.最近几天花了我很多头发.对此事的任何意见都将不胜感激.