Hello All,
A future thank you to any and all replies.
New to Angular 2/Ionic and I have a question regarding building components and attaching Inputs.
[using the Latest Ionic 2 Build with RC4]
I’ve built a checkbox component and in that component I’ve created inputs to attach form group and control names.
Often times all I really want to do is use the check box with it being in a form.
Is there a way I can make attaching my formControl and controlName OPTIONAL?
<label>
<input type="checkbox"
[formControl]="formName.controls[controlName]" ***OPTIONAL?
(click)="onClick()"/>
<div class="check-square">
<div class="check-inner-square">
</div>
</div> {{label}}
</label>
and my ts
import {Component, Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'primary-checkbox',
templateUrl: 'build/directives/checkbox/checkbox.html'
})
export class Primarycheckbox {
@Output() change = new EventEmitter();
@Input() label: string;
@Input() formName; //make this optional?
@Input() controlName; //make this optional?
onClick() {
console.log("clicking check box");
this.change.emit();
}
}
I have tried putting
[formControl]="formName.controls[controlName]
as whole input but that does not seem to work.
Thanks Again.