I am new to using directives in Angular and I have encountered an issue that I need help with. I have a file called common.js which contains the following method:
function showAlert(value) {
alert(value);
}
Within my directive:
app.directive('ccDecimalinput', function($timeout, $parse){
var FOCUS_CLASS = "error_tip error";
var templateOut = '';
// console.log('ccDecimalinput ... ');
return {
restrict: 'E',
require: 'ngModel',
scope : {
ngModel: '='
},
template: '<div ng-form="signup_form"><input type="text" class="maxlength_10_text left_aligned" id="' + attrs.id + '" name="' + attrs.name + '" ng-model="ngModel" required ng-minlength="1" ng-maxlength="10" /></div>',
replace : true,
link: function(scope, ele, attrs, c) {
scope.$watch('ngModel', function() {
if (scope.signup_form.$dirty && scope.signup_form.$invalid) {
//TODO
//I want to use the showAlert method from the common.js file here.
//....
}
});
}
}
});
Can anyone assist me with this?