使用此代码:
<!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"
。知道如何解决这个问题吗?我将编写一个指令来监听change
输入,上传给定文件并将其值分配给绑定模型。但是我这个错误阻止了我这样做。前几天花了我不少头发。任何有关此事的意见将不胜感激。