Kiara Grouwstra
Kiara Grouwstra

Reputation: 5923

ng2 input "Can't bind to <input> since it isn't a known native property"

I'm trying to pass an input to a component as described here:

<comp [str]="json"></comp>

This yields me an error:

Template parse errors: Can't bind to 'str' since it isn't a known native property ("<comp [ERROR ->][str]="json"></comp>")

I also tried switching to the <comp str="{{json}}"></comp> notation... though the error remained.

I've tried to add the input both as:

@Component({
  inputs: ['str'],
})

as well as as:

export class Comp {
  @Input() str: string;

So far no configuration seemed to solve the error though...

What's up with that?

Upvotes: 1

Views: 868

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657288

I assume you didn't add Comp to the providers of the parent element. If the <comp> tag doesn't become a Comp Angular component, it doesn't have the str property.

Upvotes: 2

Related Questions