Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Last active April 2, 2021 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/1364ca70d12912f03679c63cad7c284c to your computer and use it in GitHub Desktop.
Save NetanelBasal/1364ca70d12912f03679c63cad7c284c to your computer and use it in GitHub Desktop.
@Component({
selector: 'app-checkbox',
template: `
<-- this will be the native input element which will hide with CSS -->
<ng-content></ng-content>
<label [for]="id">
<-- add checkbox style here -->
<ng-content select="[checkboxLabel]"></ng-content>
</label>
`
})
export class CheckboxComponent {
id = guid();
@ContentChild(TogglerRefDirective) set input(input: TogglerRefDirective) {
input.setId(this.id);
}
}
@NgModule({
imports: [CommonModule],
declarations: [CheckboxComponent],
exports: [CheckboxComponent, TogglerRefDirectiveModule],
})
export class CheckboxModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment