Search code examples
angularangular2-servicesplunker

angular 2 getting plunker to work


Hi I'm want to enter an angular 2 plunk and i'm stuck already by trying to provide a service...

I've added the TestSerivce inside the ngModule under

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App ],
  bootstrap: [ App ],
  providers: [TestService]
})

and here the Service

@Injectable()

export class TestService{
  constructor(){
    console.log('Service')  
  }

}

It should be RC5 and its throwing the following error

zone.js:323 Error: (SystemJS) ReferenceError: TestService is not defined at eval (http://run.plnkr.co/BSJ1Mhu8FJ6lsnSD/src/app.ts!transpiled:46:37) at execute (http://run.plnkr.co/BSJ1Mhu8FJ6lsnSD/src/app.ts!transpiled:51:14) Error loading http://run.plnkr.co/BSJ1Mhu8FJ6lsnSD/src/main.ts

Here's the plunk


Solution

  • You have a typo in your app.ts module, it should be TestService, not TestSerivce:

    import { TestSerivce TestService } from './service.ts'