K
K
kolyalesha2016-07-04 19:59:57
Angular
kolyalesha, 2016-07-04 19:59:57

How to use Http in angular2 entities?

How to correctly use Http in User if User is not Injectable

export class User {
    name: string;
    email: string;

    constructor(userInfo:any) {
        this.name = userInfo.name;
        this.email = userInfo.email;
    }

    save() {
        // Здесь Http
       //this.http.post('url', this);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-07-04
@kolyalesha

How to correctly use Http in User if User is not Injectable

no way. Use http in some separate service which is responsible for saving the data. The entity should not know where and how it is stored.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question