【发布时间】:2014-03-18 20:17:31
【问题描述】:
这是我的 angularjs 代码:
$scope.attachments = [];
$scope.uploadFile = function(files){
for(var i=0; i<files.length; i++){
$scope.attachments.push(files[i]);
console.log($scope.attachments.length);
}
};
这里是html代码:
<input multiple ng-class="{true:'btn btn-success', false:'btn btn-danger'
[fileUploadedStatus]" style="width:15em" type="file" name="file"
onchange="angular.element(this).scope().uploadFile(this.files)"/>
{{attachments.length}}
<ul>
<li ng-repeat="attachment in attachments">
attachment: {{attachment.name}}
</li>
</ul>
我正在尝试列出所有文件。但是 $scope.attachments 变量不会更新,我可以在控制台日志中看到 attachments.length 得到 1 和 2 等等,但在页面上它始终是 0。
【问题讨论】:
标签: javascript html angularjs angularjs-scope