'Angular and TypeScript: Cannot find name 'Note'.ts(2304)
I am creating a notes app, when adding Note in the service I get the following: Cannot find name Note
This is the code:
export class DataService {
constructor(private firestore: Firestore) { }
getNotes(): Observable<Note[]>{
const notesRef = collection(this.firestore, 'notes');
return collectionData(notesRef,{idField:'id'}) as Observable<Note[]>;
}
getNoteById(id): Observable<Note>{
const noteDocRef = doc(this.firestore, `notes/${id}`);
return docData(noteDocRef, {idField: 'id'}) as Observable<Note[]>;
}
addNote(note: Note){
const notesRef = collection(this.firestore, 'notes');
return addDoc(notesRef, note);
}
deleteNote(note: Note){
const noteDocRef = doc(this.firestore, `notes/${note.id}`);
return deleteDoc(noteDocRef);
}
updateNote(note: Note){
const noteDocRef = doc(this.firestore, `notes/${note.id}`);
return updateDoc(noteDocRef, {nombre: note.nombre, descripcion: note.descripcion});
}
}
Solution 1:[1]
import { Injectable, } from '@angular/core';
import { Firestore, collectionData, docData, doc, addDoc, } from '@angular/fire/firestore';
import { collection, deleteDoc, updateDoc} from 'firebase/firestore';
import { Observable, } from 'rxjs';
@Injectable({
providedIn: 'root'
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Fernando De la cruz |