1. Component
2. Http
3. Observable
4. ngfor
5. Function
6. Subscribe
7. Service
8. json
- The HTTP get request will hit a web API or a webservice which will fetch the data from a DB and send it back as an HTTP response.
- The response we get back from the HTTP call , is an observable
- A sequence of items that arrives asychronously over time.
- Subscribe() is a method from the rxjs library.
- The Subscribe operator is the glue that connects an observer to an Observable.
3. If you can imagine yourself subscribing to a newsletter, every time there is a new newsletter,
they will send it to your home (the method inside subscribe gets called).
getAllEmployee(){
this.api.getEmployee().subscribe({
next:(res:any)=> {
console.log(res);
this.list =res;
},
error:()=>{
alert("Error while fetching data")
}
})
}