我很認真地惹毛之間ngModel。我已經嘗試了一切。 FormsModules,ReactiveForms,FORMDIRECTIVES,輸入,輸出我一直在搜索無處不在的組件之間如何使ngModel可用。我想在h1標籤顯示利用串插在輸入標籤刪除其在鍵入值/,但它不工作,這些都是文件: app.component.html:如何使可用的組件
<div class="container text-center" id="headerCont">
<a href="index.html"><span style="color: #6E2435" class="header">note</span><span style="color: #6BBFDE" class="header">it</span></a>
</div>
<div class="container">
<app-input></app-input>
<app-notes></app-notes>
</div>
app.component.ts
import { Component, OnInit, Input, Output } from '@angular/core';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
notes.component.html
<div class="col-xs-2">
<h1>{{ TitleInput }}</h1>
<p>{{ noteInput }}</p>
</div>
input.component.html
<div class="container" id="noteCreate">
<form id="titleInputForm">
<input type="text" [(ngModel)]="TitleInput" name="TitleInput">
</form>
<form>
<textarea name="name" rows="8" cols="80">
</textarea>
</form>
</div>
它目前沒有「可用」的方式?您是否收到特定的錯誤訊息?什麼都沒有發生?它召喚不死生物的嚎叫嗎? –
你是什麼意思?如何讓ngModel在組件之間可用?你真的想把變量分享給另一個組件嗎?或類似的東西? – masterpreenz
@RobertColumia沒有任何反應。當我在appcomponent中使用字符串插值時,工作正常 – Raptrozz