我正在尝试将我存储在firebase列表中的信息取回。
在我的home.ts文件中,我扫描条形码中的数据,如下所示:
async storeBarcode(){
this.db.list('barcode').push(this.resultsUI);
let alert = this.alertCtrl.create({
title: 'Bar code stored',
buttons: ['OK']
});
alert.present();
}
然后我将这些数据存储在firebase上的列表中,如下所示:
this.db.database.ref('/barcode/').on('value', resp => {
console.log(resp)
this.dbBarcode = (resp);
});
如何找回这些数据?我输了。
我一直在尝试,但没有运气
<div *ngIf="dbBarcode">
<p>From Databse</p>
<p>Database code :{{dbBarcode.text}}</p>
然后在我的home.html中显示如下结果:
@Component({
templateUrl: 'app.html',
template: `
<ul>
<li *ngFor="let item of items | async">
{{ item | json }}
</li>
</ul>
`,
})
export class MyApp {
rootPage:any = HomePage;
items: Observable<any[]>;
constructor(platform: Platform, statusBar: StatusBar, splashScreen:
SplashScreen, db: AngularFireDatabase) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
this.items=db.list('barcode').valueChanges();
});
}
}
虽然
仍未获得我想要的数据新密码!!!
app.component.ts中的
this.itemsRef = this.db.list('barcode');
this.itemsRef.snapshotChanges(['child_added'])
.subscribe(actions => {
actions.forEach(action => {
console.log(action.text);
this.dbBarcode = (action.text);
});
});
}
在home.ts中,当我想要返回数据库内容时,我有一个单击按钮
async getBarcode(){
final class PreviewView: UIView {
// 1
override class var layerClass: AnyClass {
return AVCaptureVideoPreviewLayer.self
}
.
.