i am trying to access a simple method from a service class in a component.
//myfriend.service.ts
export class MyFriendService(){
constructor(){}
testMe() {
window.alert("im friend service");
}
}
//myfriend.component.ts
import {Component} from 'angular2/core';
import {MyFriendService} from 'app/components/myfriend/myfriend.service';
@Component({
directives: [],
providers: [MyFriendService],
templateUrl: `app/components/myfriend/myfriend-view.html`
})
export class MyFriendCmp {
constructor(myFriendService: MyFriendService) {
myFriendService.testMe();
}
}
it is throwing an error
myFriendService.testMe is not a function.
I spent a lot of time in this to get this work.but still trying.Help me to figure this out. Thanks!.