formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.23k stars 406 forks source link

how to add dynamic class for formly-field based on controller property #737

Open Lalithachanta opened 7 years ago

Lalithachanta commented 7 years ago

Hi,

I need to add conditional Class to Form Field based on control property.

for Ex : i have in my controller $scope.isIssueFixed = true; and my formly object is - $scope.formly = { className: 'col-xs-6', key: 'products.device[0].deviceCommonName', type: 'input', templateOptions: { label: 'Common Device Name' }

Now how we can add a condition class to above formly field, $scope.isIssueFixed?'ok':'No'; in formly object?

egucciar commented 6 years ago

Maybe you can wire something up with ng model attributes and expression properties?

http://angular-formly.com/#!/example/very-advanced/ngModelAttrs