angularjs - How to set attributes dynamically using Angular? -
the problem is: receive json server, contains inputs description, like: {"name":"audio bitrate","description":"","type":"int","value":"128","validators":{"between":{"class":"zend\\validator\\between","parameters":{"min":"30","max":"500","inclusive":"1"}}}}
.
in ng-repeat
go through json , create custom inputs (name, type, defaul value). inputs have validators, rewritten in angular derictives check inputs before sending. in case need add between
derictive name, min="30"
, max="500"
, inclusive="1"
input attributes, i.e.
<input between type="number" class="form-control input-sm" placeholder="{{value.description|translate}}" ng-model="preset.parameters.common[parameter]" ng-init="preset.parameters.common[parameter] = (value.value - 0)" min="30" max="500" inclusive="1">
different inputs might have different validators or none of them (no ng-attr-*
, c-class
directives), did try bind attributes {{value.key}}
, doesn't work.
how can achieve goal of dynamic attribute binding? thank you.
Comments
Post a Comment