2016-04-11 14 views
0

Ich habe diesen Service:Fehler beim Konstruktor

import {Injectable} from 'angular2/core'; 
import {Http, Headers} from 'angular2/http'; 
import 'rxjs/Rx'; 

@Injectable() 

export class DataService() { 

    constructor(private _http: Http) {} 


} 

Dies wirft diesen Fehler:

Error: Zone</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:1243:21 
    [email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:1220:21 
    [email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:468:17 
    [email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:480:18 
    [email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:451:12 
    @http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:123:10 
    Zone</[email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:1243:21 
    [email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:1220:21 
    [email protected]://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:262:10 

    Evaluating http://localhost:3000/app/data.service.js 
    Error loading http://localhost:3000/app/data.service.js as "./data.service" from http://localhost:3000/app/app.component.js 
addToError() 

Irgendwelche Ideen, warum?

+0

Ja, das ist mein root.ts: Import {Bootstrap} von ‚angular2/Plattform/Browser '; Importieren Sie {AppComponent} aus "./app.component"; Importieren Sie {HTTP_PROVIDERS} von "angular2/http"; bootstrap (AppComponent, [HTTP_PROVIDERS]); – Satch3000

Antwort

1

Sie Klammern direkt nach dem Klassennamen entfernen sollte:

@Injectable() 
export class DataService { // <----------- 

statt

@Injectable() 
export class DataService() { // <----------- 
Verwandte Themen