angular input variable code example
Example 1: how to make input in angular optional
export class ChildComponent {
@Input() showName?: boolean;
constructor() { }
}
Example 2: input set variable angular
@Component({
selector: 'my-component',
template: '<h3> My component </h3>'
})
export class MyComponent {
@Input()
set name(str: string) {
this.service.setName(str);
console.log(str);
}
}