का उपयोग कर मेरे पास एक इनपुट प्रकार = फ़ाइल तत्व है। जैसे ही मैं इनपुट तत्व का उपयोग कर फ़ाइल का चयन करता हूं, मैं फ़ाइल आकार की जांच के लिए एक कस्टम निर्देश बनाना चाहता हूं। मुझे पता है कि एक कस्टम निर्देश बनाने के लिए कैसे, लेकिन चयनित तत्व के फ़ाइल आकार को निर्धारित करने के लिए angularjs में कोई तरीका है। कोई jquery का उपयोग किया जाना है।इनपुट प्रकार = फ़ाइल के लिए अपलोड करने से पहले फ़ाइल आकार को सत्यापित करें angularjs
js कोड:
app.directive('checkFileSize',function(){
return{
require: 'ngModel',
link: function(scope, elem, attr, ctrl) {
// add a parser that will process each time the value is
// parsed into the model when the user updates it.
ctrl.$parsers.unshift(function (value) {
//i want to do something like this
var fileSize= // get file size here
if(fileSize>threshold){
ctrl.$setValidity('checkFileSize',false);
}
// return the value to the model,
return someValue;
});
}
}
});
हाँ, यह संभव है , लेकिन एंग के लिए विशिष्ट नहीं है ular -http: //stackoverflow.com/questions/3717793/javascript-file-upload-size- प्रमाणीकरण। आप आसानी से इसे कोणीय सत्यापन निर्देश – pixelbits
ए I में शामिल कर सकते हैं: क्या आप अपने लिए काम करने वाले समाधान को समेकित और प्रदान कर सकते हैं। धन्यवाद ! – PavanSandeep