I know these kind of questions have been asked many time before but none of them working for me. I'm new to directive working, may be its lack of learning that I'm unable to resolve my issue.
I've a variable in directive that I need in controller but there's no way to pass that value. Here is my directive code
return {
restrict: 'A',
require: 'ngModel',
scope: {
image: '=ngModel',
allowedTypes: '@accept',
dimensionRestrictions: '&dimensions',
},
link: function($scope, element, attrs, ngModel) {
element.bind('change', function(event) {
var file = (event.srcElement || event.target).files[0];
ngModel.$setViewValue(file, 'change');
});
};
}
I need file
variable in controller but I don't know how to do this...
I've tried this fiddle but its not working in my case.
Any Kind of help will be appreciated.