I am trying to define a custom property count. But following gives error:Can't bind to 'count' since it isn't a known property of 'p'. How to remove this error and make count a custom property of <p>
other.component.html
<p [count] = "10">
other works!
</p>
other.component.ts
import {Component, Input, OnInit} from '@angular/core';
@Component({
selector: 'app-other',
templateUrl: './other.component.html',
styleUrls: ['./other.component.css']
})
export class OtherComponent implements OnInit {
@Input() count = 10;
constructor() { }
ngOnInit() {
}
}
<p>
doesn't have a name
property.
You can bind to the name
attribute using
[attr.name]="name"
or alternatively
attr.name="{{name}}"
Use this 2nd form (interpolation) only for binding string values, because the passed value will always be stringified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With