I am trying to figure out how to properly inject http into my class using es6. When I use @inject I get an error saying inject is not defined
. Am I missing something else I must import for inject to work here?
import 'zone.js/lib/browser/zone-microtask';
import 'reflect-metadata';
import 'babel-polyfill';
import {provide} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {Http, Headers} from 'angular2/http';
import {Component, View, Input} from 'angular2/core';
import {RouteConfig, RouteParams, ROUTER_DIRECTIVES} from 'angular2/router';
@Component({
selector: 'test-app',
template: '<div>Hello my name is {{name}}. <button (click)="sayMyName()">Say my name</button></div>'
})
@inject('Http')
export class TestApp
{
constructor(http)
{
this.name = 'Allencoded';
this.http = http;
}
sayMyName()
{
console.log('My Name is ', this.name);
console.log(this.http);
}
}