Skip to content

getting error 404 not find #11602

Closed
Closed
@nbansal1

Description

@nbansal1

import { PostService } from './../services/post.service';
import { Component, OnInit } from '@angular/core';

@component({
selector: 'app-posts',
templateUrl: './posts.component.html',
styleUrls: ['./posts.component.css']
})
export class PostsComponent implements OnInit {
posts : any[];

constructor(private service : PostService) {

}
ngOnInit(){
this.service.getPost()
.subscribe(response => {
this.posts = response.json();
});
}
createPost(input : HTMLInputElement){
let post = {title : input.value};
input.value='';
this.service.createPost(post)
.subscribe(response =>{
post['id'] = response.json().id;
this.posts.splice(0,0,post);
}
);
}
updatePost(post){
this.service.updatePost(post)
.subscribe(response => {
console.log(response.json());

 })

}
deletePost(post){
this.service.deletePost(post.id)
.subscribe(response =>{
let index = this.posts.indexOf(post);
this.posts.splice(index , 1);
}
)
}

}
capture

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions