angular2 map data as specific object type
<p>I created a very simple app based on the Angular2 tutorial. </p>

<p>To start, I have a very simple "Book" model:</p>

<pre><code> /**
 * book model
 */
export class Book {
    public data;

    /**
     * constructor
     * @param id
     * @param title
     * @param pages
     */
    constructor(
        public id,
        public title:string,
        public pages:Array
    ){
        alert('it works'); // just a check
    }
}
</code></pre>

<p>In my service, I get a book like this:</p>

<pre><code>return this._http.get('getBook/1')
        .map(function(res){
            return &lt;Book&gt; res.json();
        })
</code></pre>

<p>My expectation was that this would get the resulting JSON data and "map" it to a Book object.</p>

<p>However, it just returns an object with type "Object".</p>

<p>I could create a new Book object myself and pass the parameters in the constructor, like this:</p>

<pre><code>return new Book(res.id, res.title, res.pages);
</code></pre>

<p>Is this the best way to do this? Did I miss something?</p>