0
无法将数组传递给Angular中的输入掩码插件。 也许有人可以帮助我。无法将数组传递给角度指令
angular.module('myproject.directives').
directive('inputMask', function() {
return {
restrict: 'A',
scope: {
inputMask: '@'
},
link: function(scope, el, attrs) {
$(el).inputmask(attrs.inputMask);
}
};
});
<input type="text" input-mask="{'mask': '9{4} 9{4} 9{4} 9{4}[9]', 'autoUnmask': 'true'}" />
问题可能是单引号。 – Jai
'@'属性告诉指令期望一个字符串,所以你可以将它传递给一个字符串,然后将它处理成一个数组,该指令可以在链接函数中理解。不过,您在input-mask属性中显示的内容看起来不像数组。 –