@Attribute() | @Input() | |
---|---|---|
Availability | In constructor through dependency injection |
After component/directive initialization, in ngOnInit life-cycle hook |
Type support | string |
all |
General usage | HTML attribute | DOM property or custom data |
Code Snippets | ||
<smart-input type="text"></smart-input> |
Works, value is text |
Works, value is text |
<smart-input [type]="'text'"></smart-input> |
Doesn’t work, throws error NG8002 | Works, value is text |
<smart-input type="{{ 'text' }}"></smart-input> |
Doesn’t work, throws error NG8002 | Works, value is text |
<smart-input [attr.type]="'text'"></smart-input> |
Doesn’t work, value is null |
Doesn’t work, value is undefined |
Created
August 27, 2021 16:04
-
-
Save shhdharmen/c7e6f2394508e7f0d31920fad40f3165 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment