Nick Nick - 19 days ago 7
AngularJS Question

Angular 2: is not a function but it exist

I am trying to get an array out of a different class but he says the function does not exist.
here is my code:

import {Component} from 'angular2/core'
import {CourseService} from './course.service'

@Component({
selector: 'courses',
template: `
<h2>Courses</h2>
{{ title }}
<ul>
<li *ngFor ="#course of courses">
{{course}}
</li>
</ul>
`,
providers: [CourseService]
})
export class CoursesComponent{
title = "The title of courses page";
courses;

constructor(courseService: CourseService){
this.courses = CourseService.getCourses();
}
}


this document is named courses.component.ts

I also got course.service.ts:

export class CourseService{
getCourses() ; string[]{
return ["Course1","Course2","Course3"];
}
}

Answer

You need to reference the argument name, not the argument type

 this.courses = courseService.getCourses();
                ^ lower case c