Although similar questions have been asked numerous times before, none of the solutions seem to work for me. I am new to working with directives and it seems like my lack of experience is hindering my ability to resolve this issue.
Within my directive, I have a variable that I need access to in the controller but I can't find a way to pass that value. Here is the code snippet for my directive:
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 require the file
variable in the controller but I'm unsure how to achieve this. I attempted to use this fiddle, however it did not work in my scenario.
Any assistance on this matter would be greatly appreciated.