I created a very simple app based on the Angular2 tutorial.
To start, I have a very simple \"Book\" model:
/**
* book model
*/
export class Book
I think you should declare an interface Book
instead of class book
:
export interface Book {
public id;
public title:string;
public pages:Array;
}
In your service:
//get one record
return this._http.get('getBook/1')
.map(function(res){
return res.json();
});
//get multi record
return this._http.get('getBooks')
.map(function(res){
return res.json();
});