I am working on an Angularjs application.
I am able to call the function when selecting a file, but it does not pass the selected file into the Angularjs function. I get an undefined value in the variable selectedFile
.
I am using a trigger to open the file picker as follows:
$scope.clickUpload = function () {
angular.element('#uploader').trigger('click');
}
The following is my HTML:
<button type="submit" ng-click="clickUpload()">
<span>Upload Image</span>
</button>
<input id="uploader" hidden type="file" ng-accept="'.jpg,.png,.gif,.jpeg,.webp'" ngf-select="uploadFile(selectedFile)" ng-model="selectedFile" name="file" />
Below is my Angularjs function to upload the file that has been selected:
$scope.uploadFile = function (selectedFile) {
alert(selectedFile);
}
What is the mistake I have made? Thank you for reading my question.