Last active
April 2, 2021 15:13
-
-
Save NetanelBasal/1364ca70d12912f03679c63cad7c284c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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