javascript - Input type="file" show error when i upload a image file -
when try upload image file type input angular validation shows error , won't passes
<input type="file" name="displaypic" ng-model="displaypic" ng-pattern="/\.(jpe?g|png|gif|bmp)$/i" ng-required="true" /> <span ng-show="signupform.displaypic.$error.pattern">* must image</span>
with css input.ng-invalid.ng-touched{border: 2px solid red;}
its not show error of $error.pattern
css invalid file , didn't let form submit
you have use directive create object in controller
$scope.file={}; $scope.file.filedetail={}; <input type="file" fileupload filetoread="file.filedetail" /> .directive("fileupload ", [function () { return { scope: { filetoread: "=" }, link: function (scope, element, attributes) { element.bind("change", function (changeevent) { var reader = new filereader(); reader.onload = function (loadevent) { scope.$apply(function () { scope.filetoread= loadevent.target.result; }); } reader.readasdataurl(changeevent.target.files[0]); }); } } }]);
Comments
Post a Comment