0
我是一個新手使用指令的角度。有一個問題我需要幫助。 我有一個文件common.js。該文件內容的方法:如何調用指令外的方法?
function showAlert(value) {
alert(value);
}
而且在指令:
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 method showAlert in common.js file here.
//....
}
});
}
}
});
有人幫幫我嗎?
是的。有用。我錯了,因爲rem腳本在html中 – vodanh