我想使用AngularJS上传文件,但我无法在ng-controller中获取该文件。它显示为未定义。下面是HTML和AngualrJS代码。请帮忙。
<form id="upload" enctype="multipart/form-data" method="post" data-ng-submit="uploadFile()">
<p>
<div class="form-group">
<input type="file" file-model="myFile" />
</div>
</p>
<button type="submit">Upload</button>
</form>
&#13;
'use strict';
var UploadFileController = angularApp
.controller(
'UploadFileController',
function UploadFileController($scope, $rootScope,
UserDataService, $http, $location, $window,
UtilService, CommonDataService, ControllerService) {
$scope.uploadFile = function() {
var nameFile = $scope.myFile;
console.log("Uploaded file====>>> ", nameFile);
};
$scope.init = function() {
console.log("Upload Controller InitApp");
}
angular.element(document).ready(function() {
$scope.init();
});
});
&#13;