I am doing something wrong with my simple service but I can not figure it out.
app.component.ts
import { MeetingService } from '../../shared/services/meeting.service';
@Component({
viewProviders: [MeetingService],
})
meetingService.ts
@Injectable();
export class MeetingService {
constructor(private http: Http) {}
getList() {
return this.http.get('../fake-data/meetingList.json')
.map(response => response.json());
}
}
meetingList.component.ts
import { MeetingService } from '../../shared/services/meeting.service';
@Component({
viewProviders: [HTTP_PROVIDERS, MeetingService],
})
export class MeetingListComponent {
private meetingList: any;
constructor(private meetingService: MeetingService) {}
getList() {
this.meetingService.getList().subscribe(
data => { this.meetingList = data; },
err => console.error(err),
() => console.log('done loading meeting list')
);
}
ngOnInit() {
this.getList();
}
}
Error
EXCEPTION: Cannot resolve all parameters for 'MeetingService'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'MeetingService' is decorated with Injectable.
Can somebody take a look at it? Thank you.