Save data using InMemoryBackendService in Angular 2

1

I'm trying to save data using this module from Angular 2

in-memory-users.ts

export class InMemoryDataService {
      createDb() {
      let usuarios = [
      { id: 5 , nombre: "juan" , nick: "kevinlll4" , email: "[email protected]"},
      { id: 6 , nombre: "juadn" , nick: "kevinlll4" , email: "[email protected]"},
      { id: 7 , nombre: "juadn" , nick: "kevinlll4" , email: "[email protected]"},
      { id: 8 , nombre: "juan" , nick: "kevinlll4" , email: "[email protected]"}
    ];
        return {usuarios};

      }
    }

Method with which I save new users.

user.service.ts

private post(user: User): Promise<User> {
  let headers = new Headers({
    'Content-Type': 'application/json'});

  return this.http
             .post(this.usersUrl, JSON.stringify(user), {headers: headers})
             .toPromise()
             .then(res => res.json().data)
             .catch(this.handleError);
}

I see that when I add the user it appears added in the list, but when I update the page, it is as if it had not been added.

    
asked by Kevin AB 24.07.2016 в 06:57
source

0 answers