nstudio / nativescript-checkbox

NativeScript plugin for checkbox UI component
Other
119 stars 56 forks source link

Cannot pass angular variable to boxType Property #115

Open mmerbes opened 5 years ago

mmerbes commented 5 years ago

I am trying set the Checkbox boxType property to the passed variable so it can be either a radio button or checkbox depending on the needs of the component.

        <StackLayout orientation="horizontal" verticalAlignment="center">
            <CheckBox #elem [checked]="option.selected"
                      (checkedChange)="elem.checked !== option.selected && changeCheckedRadio(option)"
                      class="checkbox"
                      [fillColor]="aColor"
                      [boxType]="boxType">
            </CheckBox>
            <StackLayout verticalAlignment="center">
                <Label [text]="option.text" textWrap="true" (tap)="changeCheckedRadio(option)"></Label>
            </StackLayout>
        </StackLayout>
export class CheckboxQuestionComponent implements OnInit, SurveyQuestion {
  radioOptions: Array<CheckboxOption>

  @Input() radio: boolean = false
  @Input() question: Question
  boxType: string = 'circle'
  aColor: any = 'Red'
  constructor () {
  }

  ngOnInit () {
    this.boxType = this.radio ? 'circle' : 'square'
  }

It should be noted that setting the fillColor through an angular variable works perfectly but the boxType fails to do the same.

PabloPG commented 4 years ago

You need to create two checkbox with *ngIf