ユーザーがテキストを入力した後、入力時に何らかの精製を行うカスタムフィルターを介してテキスト値が渡されるように、テキスト型の入力を角度で拡張したいのですが、これが私が今までやってきたことですが、私はエラーが発生する:
angular.js:13920 TypeError: Cannot read property 'length' of undefined
at addDirective (http://bank.com:4000/vendor/bower_components/angular/angular.js:9495:35)
at collectDirectives (http://bank.com:4000/vendor/bower_components/angular/angular.js:8677:11)
at compileNodes (http://bank.com:4000/vendor/bower_components/angular/angular.js:8539:22)
ここに私が書いたものがあります:
angular.module('app').config(extendInputDirective);
function extendInputDirective($provide) {
$provide.decorator('inputDirective', function($delegate, $filter) {
debugger;
var directive = $delegate[0];
var link = directive.link;
directive.compile = function() {
return function(scope,element, attrs, ngModel) {
debugger;
if(attrs.type === 'text') {
ngModel.$parsers.unshift(function(viewValue) {
var value = $filter('pArabicCharFilter')(viewValue);
return value;
});
}
link.apply(this, arguments);
}
}
});