javascript - Cannot pass array to angular directive -


cannot pass array input mask plugin in angular. maybe can me this.

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'}" /> 

the attribute value return string , not object needed pass plugin

you can switch quotes around string valid json , parse json object

<input type="text" input-mask='{"mask": "9{4} 9{4} 9{4} 9{4}[9]", "autounmask": "true"}' /> 

js

.directive('inputmask', function() {     return {         restrict: 'a',         scope: {             inputmask: '@'         },         link: function(scope, el, attrs) {           var mask =json.parse(attrs.inputmask);            $(el).inputmask(mask);         }     }; }) 

but realistically simpler not putting string in html , passing object reference controller isolated scope instead


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -