So what i want is to pass a variable for maxlength property of an input
<input my-dir="maxLenght" id="inputScannedCode"
type="text" ng-model="ScannedCode" maxlength="20"
class="form-control orange-shadow"
required placeholder=" Scan the code " />
So i want the length of the input to be set from a constant for consistency.
so i've created a custom directive so that it changes the maxlength value.
.directive('myDir', function () {
return {
restrict: 'A',
scope: {
myDir: '='
},
template: '<div>{{myindex}}</div>',
link: function (scope, element, attrs) {
//console.log(attrs);
//attrs.maxlength = scope.myDir.toString();
//attrs.placeholder = scope.myDir.toString();
}
};
})
Indeed this changes my maxlength value but it does after compile but when i inspect my element it still shows maxlengh="20".
Any ideas what i need to do?