Reputation: 144
event-component.ts
EventService is the service class Injectable but i have getting error [ts] cannot find module '/shared/event.service' but app.module.ts i was giving same path of this service it is working their. path is correct please tell me whats wrong in this..
import { Component } from '@angular/core'
import { EventService } from '/shared/event.service'
//[ts] Cannot find module '/shared/event.service'.
@Component({
selector: 'event-list',
template: `<div><h2>we are using Angular Js 2</h2><hr/>
<div class="row">
<div class="col-md-6" *ngFor="let event of events">
<event-thumbnil [eventList] = "event" >
</event-thumbnil>
</div>
</div>
</div>`
})
export class EventsListComponent {
events:any[]
constructor(private eventService : EventService)
{
this.events= this.eventService.getEvents();
}
}
app.module.ts
import { NgModule } from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import {EventsAppComponent } from './events-app.component'
import { EventsListComponent } from './Events/events-list.component'
import {EventThumbnilComponent } from './Events/events-list.thumbnil'
import {NavabarComponent} from './nav/navbar-component'
import {EventService} from './shared/event.service'
@NgModule({
imports:[BrowserModule],
declarations: [EventsAppComponent, EventsListComponent,EventThumbnilComponent,NavabarComponent],
bootstrap:[EventsAppComponent],
providers:[EventService]
})
export class AppModule{
}
Upvotes: 0
Views: 622
Reputation: 752
in your typescript file you forget to give the directory for you service
import {EventService} from '../shared/event.service'
check it out it may works
Upvotes: 1