爲什麼輸入綁定不起作用?我採用了由IntelliJ創建的框架代碼,並用我的組件my-para
替換了默認的app
組件。以下是代碼片段。輸入綁定在Angular/IntelliJ中不起作用
的index.html
<body>
<my-para [paratext]="say something"></my-para>
</body>
paragraph.component.ts
import {Component, Input } from "@angular/core";
@Component({
selector: 'my-para',
inputs: ['paratext'],
template:`
<p>Hello {{this.paratext}}</p>
`
})
export class MyParaComponent {
@Input() paratext: string;
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {MyParaComponent} from './paragraph.component'
@NgModule({
declarations: [
MyParaComponent,
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [MyParaComponent]
})
export class AppModule { }
我看到的只有 「你好」,而不是「你好說點什麼「
' '。這個「說些什麼」的部分需要是一個字符串。但是代碼中有很多冗餘行。請按照官方文檔:https://angular.io/tutorial –
echonax
對不起,沒有工作 –