sud*_*mar 6 angularjs angular-template angular
它显示模板有错误,
错误:
我的html
<input type="text" [(ngModel)]="mymessage"
<button (click)="clickMe()"> send</button>
<br><br>
<h1>{{result | json}}</h1>
Run Code Online (Sandbox Code Playgroud)
我的组件.ts
import {Component} from "@angular/core";
export class MyComponent {
private result: any;
constructor()
}
Run Code Online (Sandbox Code Playgroud)
所以这里的错误说它无法在 uppercase.component.ts 中找到变量“mymessage”
export class UpperCaseComponent {
public results: any; // Change it private to public
public mymessage: any;
}
Run Code Online (Sandbox Code Playgroud)
如果您尝试访问模板中的变量,则需要将其声明为公共变量,就像将其声明为私有变量一样,它只能在类中访问
| 归档时间: |
|
| 查看次数: |
92028 次 |
| 最近记录: |