显示模板错误,
错误:
- 属性“result”是私有(private)的,只能在“upperCaseComponent”类中访问
- 属性“mymessage”未在“upperCaseComponent”中声明
我的html
<input type="text" [(ngModel)]="mymessage"
<button (click)="clickMe()"> send</button>
<br><br>
<h1>{{result | json}}</h1>
我的组件.ts
import {Component} from "@angular/core";
export class MyComponent {
private result: any;
constructor()
}
最佳答案
所以这里的错误说它无法在 uppercase.component.ts 中找到变量“mymessage”
export class UpperCaseComponent {
public results: any; // Change it private to public
public mymessage: any;
}
如果你试图在模板中访问变量,你需要将它声明为公共(public)的,就像你将它声明为私有(private)的一样,它只能在类中访问
关于angularjs - 组件upperCaseComponent模板出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59420966/