TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Usama Shahid
NA
9.5k
2.3m
How to get the key in Update() of Firebase record in Angular
Sep 5 2018 2:05 PM
Hy Friends,
I'm developing CRUD application with Angular using Firebase database. I've already seen many tutorials and articles, but it doesn't make any sense to me. Most of them defining a Model class with key attribute. But in my case, I've defined the firebase schema
Here 1 is the key and course1 is the value. My component code is
export
class
AppComponent {
courses$;
course: AngularFireList;
constructor(
private
db: AngularFireDatabase) {
this
.courses$ = db.list(
'/courses'
).valueChanges();
}
add(course: HTMLInputElement) {
if
(!
this
.course) {
this
.course =
this
.getData();
}
this
.course.push({
name: course.value,
price: 150,
isLive:
true
,
sections: [
{ title:
'Component'
},
{ title:
'Service'
},
{ title:
'Template'
}
]
});
course.value =
''
;
}
getData() {
return
this
.db.list(
'/courses'
);
}
update(course) {
console.log(course);
}
}
And my html template code is
<
input
type
=
"text"
(keyup.enter)="add(course)" #course
>
<
ul
>
<
li
*
ngFor
=
"let course of courses$ | async"
>
{{ course.name || course }}
<
button
(click)="update(course)"
>
Update
</
button
>
</
li
>
</
ul
>
Problem
: How can I update and delete firebase record with Angular. I need update() and delete() method code of Angular 4+. Bundle of thanks in advance.
Reply
Answers (
0
)
How to implement Export to excel in angular 2
Min date and maximum date in angularjs.