Amigos, gostaria de ter o método salvar na própria classe, e não estou conseguindo, sou iniciante na linguagem typeScript.
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
@Injectable()
export class Usuario {
http: Http;
nome: string;
apelido: string;
email: string;
tel: string;
senha: string;
salvar(usuario){
this.http.post("http://localhost:5000/users",JSON.stringify(usuario), {})
.toPromise()
.then(res => console.log(res.json().data))
.catch();
}
}
recebo o erro:
browser_adapter.js:84 ORIGINAL EXCEPTION: TypeError: Cannot read property 'post' of undefined
chmod
(tipo permissão)? ele esta dizendo de erro undefined está vazio.