In the general case, can't bind to xxx since it isn't a known native property error occurs when you have a typo in your HTML when trying to use the attribute directive or when trying to set a property binding.
Common examples: if you skip * or # or let or use in instead of using Angular's built-in structural directives:
<div ngIf="..." // should be *ngIf <div ngFor="..." // should be *ngFor="..." <div *ngFor="let item in items" // should be "let item of items" <div *ngFor="item of items" // should be "let item of items"
An erroneous or incorrect case will also cause a problem:
<div *ngFer="..." <div *NgFor="..."
Another reason is that you specify a property that does not exist in the DOM element or component:
<div [prop1]="..."
For typos with built-in Angular directives, since the typo does not match any of the built-in directive selectors, Angular tries to bind to the property of the DOM element ( div in the examples above) with the typo name. This does not work because the div does not have its own property ngIf or ngFer or prop1 DOM.
-
For attributes (not properties) you need to use attribute binding, for example, for the height attribute svg : <svg [attr.height]="myHeightProp">
Mark Rajcok Mar 11 '16 at 23:38 2016-03-11 23:38
source share