साथ काम नहीं कर रहा। मैं अनुप्रयोग में AngularJS v1.4.8 उपयोग कर रहा हूँ।एनजी मॉडल मैं इनपुट के बाहर फ़ाइल इनपुट का मान मिलता है और इसे कहीं और प्रदर्शित करने के लिए, कोशिश कर रहा हूँ फ़ाइल इनपुट
<input type="file" ng-model="fileName" />
<div>{{fileName}}</div>
यह दृष्टिकोण टाइप = "टेक्स्ट" के साथ ठीक काम करता है लेकिन टाइप = "फ़ाइल" के साथ नहीं।
क्यों यह इतना है और कैसे मैं इस समस्या को हल कर सकते हैं?
धन्यवाद!
एचटीएमएल:
<input type="file" file-input="files" />
<ul>
<li ng-repeat="file in files">{{file.name}}</li>
</ul>
js:
.directive('fileInput', ['$parse', function ($parse) {
return {
restrict: 'A',
link: function (scope, element, attributes) {
element.bind('change', function() {
$parse(attributes.fileInput)
.assign(scope,element[0].files)
scope.$apply()
});
}
};
}]);
यह वास्तव में this ट्यूटोरियल से एक समाधान है
यह लिंक देखें https://jsfiddle.net/JeJenny/ZG9re/ –
http://stackoverflow.com/questions/17063000/ng-model-for-input-type-file –