我正在尝试定义自定义属性计数.但是后面给出了错误:无法绑定到'count',因为它不是'p'的已知属性.如何删除此错误并使计数成为自定义属性<p>
other.component.html
<p [count] = "10">
other works!
</p>
Run Code Online (Sandbox Code Playgroud)
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() {
}
}
Run Code Online (Sandbox Code Playgroud)
Gün*_*uer 10
<p>没有name财产.您可以使用绑定到该name属性
[attr.name]="name"
Run Code Online (Sandbox Code Playgroud)
或者
attr.name="{{name}}"
Run Code Online (Sandbox Code Playgroud)
仅将此第二种形式(插值)用于绑定字符串值,因为传递的值始终是字符串化的.
| 归档时间: |
|
| 查看次数: |
6943 次 |
| 最近记录: |