Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Firebase可观测目标预填充离子2离子输入场_Firebase_Ionic Framework_Firebase Realtime Database_Ionic2_Angularfire - Fatal编程技术网

如何从Firebase可观测目标预填充离子2离子输入场

如何从Firebase可观测目标预填充离子2离子输入场,firebase,ionic-framework,firebase-realtime-database,ionic2,angularfire,Firebase,Ionic Framework,Firebase Realtime Database,Ionic2,Angularfire,我们使用异步管道输出af.database.object的值,如下所示 import {Component} from '@angular/core'; import {AngularFire, FirebaseObjectObservable} from 'angularfire2'; @Component({ selector: 'app-root', template: ` <h1>{{ (item | async)?.name }}</h1> `

我们使用异步管道输出af.database.object的值,如下所示

import {Component} from '@angular/core';
import {AngularFire, FirebaseObjectObservable} from 'angularfire2';

@Component({
  selector: 'app-root',
  template: `
  <h1>{{ (item | async)?.name }}</h1>
  `,
})
export class AppComponent {
  item: FirebaseObjectObservable<any>;
  constructor(af: AngularFire) {
    this.item = af.database.object('/item');
  }
}
从'@angular/core'导入{Component};
从'angularfire2'导入{AngularFire,FirebaseObjectObservable};
@组成部分({
选择器:'应用程序根',
模板:`
{{(项目|异步)?.name}
`,
})
导出类AppComponent{
项目:FirebaseObjectObservable;
建造师(af:AngularFire){
this.item=af.database.object('/item');
}
}
但我一直试图在Ionic 2表单字段上执行同样的操作,以预填充表单进行编辑(在下面的代码中),但没有成功

<ion-input type="text" [(ngModel)]="product.name" name="content" value="{{ (item | async)?.name }}" required></ion-input>


这以前适用于我的Angular 2网站编辑表单。但是,当在离子2中使用离子输入场时,它似乎不起作用。

你有双重绑定,它看起来是这样的。链接product.name的ngModel上有1个值,项目上还有2个值。尝试删除ngModel上的双向绑定。您的绑定看起来是双重的。链接product.name的ngModel上有1个值,项目上还有2个值。尝试删除ngModel上的双向绑定。