无法将对象添加到Firebase

时间:2019-09-05 08:41:07

标签: angular firebase firebase-realtime-database

我正在使用Firebase在Angular中进行一个项目。我无法将对象推送到Firebase数据库。

这里是Stackblitz Example代表我的问题。

component.ts

import { AngularFireDatabase, AngularFireList } from '@angular/fire/database';
export class AppComponent {
  courses$: AngularFireList<any[]>;
  constructor(private db: AngularFireDatabase) { }
  ngOnInit() {
    this.courses$ = this.db.list('/courses');
  }
  addCourse(course: HTMLInputElement) {
    this.courses$.push(course.value);
    course.value = '';
  }
}

HTML:

<div class="form-group">
    <input type="text" class="form-control" placeholder="Enter courses..." (keyup.enter)="addCourse(course)" #course>
</div>
<ul class="list-group">
    <li class="list-group-item" *ngFor="let course of courses$ | async">{{course.value}}</li>
</ul>

1 个答案:

答案 0 :(得分:2)

caracteres_mal = 'Éü'
txt_registro = convertir_string_a_universe(txt_orig)
datos = bytes(txt_registro, 'cp1252')

  File "C:\Users\Hector\PyCharmProjects\pyuniverse\pyuniverse\UniverseRegister.py", line 138, in reconstruir_registro_universe
    datos = bytes(txt_registro, 'cp1252')
  File "C:\Users\Hector\AppData\Local\Programs\Python\Python36-32\lib\encodings\cp1252.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode character '\x90' in position 0: character maps to <undefined>

https://stackblitz.com/edit/adding-an-object-to-firebase-rnjcpj?file=src/app/app.component.ts