尝试上传图像文件并在名为onFileSelect的AngularJS函数中处理它。但是,单击“选择文件”按钮后,onFileSelect中的$ scope.fileMsg值未更新。有小费吗?非常感谢!
<div ng-app="myApp" ng-controller="myCtrl">
<form name="myForm">
<div>
<input type="file" ngf-select="onFileSelect(file)" name="file">
<span ng-show="fileMsg">{{fileMsg}}</span>
</div>
</form>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$scope.fileMsg = "Checkpoint 1";
$scope.onFileSelect = function(file) {
$scope.fileMsg = "Checkpoint 2";
}
}
);
</script>
答案 0 :(得分:1)
您必须在模块中插入'ngFileUpload',如下所示:
var app = angular.module('myApp', ['ngFileUpload']);
而且,如果你还没有,请注入必要的碎片。
这是一个工作小提琴: http://jsfiddle.net/ADukg/23032/