formly-js / angular-formly-templates-material

Angular-Formly: Material Templates
MIT License
55 stars 39 forks source link

Update radio.html #17

Closed bbeyssac closed 8 years ago

kamilkisiela commented 8 years ago

@bbeyssac Currently templateOptions.className is pointing to element with ngModel directive so in that case it is mdRadioGroup.

It would be nice if each mdRadioButton had classNameProp or something similar to valueProp and labelProp convention. So user would be able to add different classes for different options.

{
  type: 'radio',
  key: 'name',
  templateOptions: {
    label: 'Name',
    className: 'custom-options',
    labelProp: 'firstName',
    valueProp: 'id',
    classNameProp: 'className',
    options: [
        { firstName: 'Sarah', id: 1, className: 'bold'},
        { firstName: 'Jessica', id: 2, className: ['bold', 'italic'] },
        { firstName: 'Parker', id: 3 }
    ]
  }
}

Do you want to try? :) I can help you

bbeyssac commented 8 years ago

This code don't works if ng-class="to.className" is not defined in the "radio.html" template.

formlyConfigProvider.setType({
    name : 'boolean',
    extends : 'checkbox',
    defaultOptions : {
        templateOptions : {
            className : 'md-primary'
        }
    }
});

This case works, if i force class name in the fields form : { "key" : "confidential", "type : "boolean", "templateOptions" : { "className" : 'md-primary' } }

I don't undersand why.

kamilkisiela commented 8 years ago

@bbeyssac I don't know exactly what you want to achieve and what's the problem. Could you explain it to me a little bit?