Ionic2:通过组件获取页面中的输入文本字段
这是我的搜索Ionic2:通过组件获取页面中的输入文本字段,ionic2,Ionic2,这是我的搜索页面,在这里我加载带有for循环的结果 <ion-header> <ion-navbar> <ion-title>Search</ion-title> </ion-navbar> </ion-header> <ion-content padding> <ion-list> <ion-item> <ion-input
页面
,在这里我加载带有for循环的结果
<ion-header>
<ion-navbar>
<ion-title>Search</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item>
<ion-input [(ngModel)]="room_name" type="text"></ion-input>
</ion-item>
<ion-list>
<guide-view *ngFor="let g of guideList" [guide]="g"></guide-view>
</ion-list>
</ion-list>
</ion-content>
正如您所看到的,我需要输入文本的值,用于调用
openRoom
,但我不知道如何获取它。在这一行的搜索页面中
变成
然后我可以在组件中使用以下代码获取房间名称
:
export class GuideView {
@Input()
guide: Guide;
message : any;
@Input('room_name') = myRoom;
constructor(public navCtrl: NavController, public myService: MyServiceh) {}
engageGuide(guide: Guide): void{
this.myService.openRoom(this.myRoom,guide).subscribe((data)=>{
....
}
}
export class GuideView {
@Input()
guide: Guide;
message : any;
@Input('room_name') = myRoom;
constructor(public navCtrl: NavController, public myService: MyServiceh) {}
engageGuide(guide: Guide): void{
this.myService.openRoom(this.myRoom,guide).subscribe((data)=>{
....
}
}