Skip to content

Instantly share code, notes, and snippets.

@ronnyek
Created September 18, 2019 20:23
Show Gist options
  • Select an option

  • Save ronnyek/6185fbcae468c6c199b0d763d24e7f42 to your computer and use it in GitHub Desktop.

Select an option

Save ronnyek/6185fbcae468c6c199b0d763d24e7f42 to your computer and use it in GitHub Desktop.
import { Component, Input } from '@angular/core';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
@Component({
selector: 'some-component',
template: ``
})
export class SomeComponent {
private _showLabel: boolean; //set a default val if necessary
@Input()
set showLabel(value: boolean){
this._showLabel = coerceBooleanProperty(value);
}
get showLabel(): boolean {
return this._showLabel;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment