Angular

Last Updated: 9/4/2023

Creating Data

  • Use post method to create data on server
  • All the methods of http class returns observable
<input type="text" (key.enter)="createPost(title)" #title>
createPost(input: HtmlInputElement) {
	let post = {title: input.value}
	this.http.post(url, post).subscribe((value) => {
		//this.posts.splice(0, 0, value) //to add in the begining
		this.posts.unshift(post);
	})
}