Reputation: 1121
I'm developing an Angular2 application and I have the following component:
import {Component, OnInit} from '@angular/core';
import {CourseAdminService} from "../shared/course-admin.service";
import {Course} from "../shared/course";
@Component({
selector: 'app-course-admin-list',
templateUrl: './course-admin-list.component.html',
styleUrls: ['./course-admin-list.component.css']
})
export class CourseAdminListComponent implements OnInit {
courses: Course[] = [];
keyword = "";
constructor(private courseAdminService: CourseAdminService) {
}
ngOnInit() {
this.loadMore();
}
reset() {
this.courses = [];
this.loadMore();
}
loadMore() {
let since: Date = null;
let before: Date = null;
let len = this.courses.length;
if (len > 1000) {
since = this.courses[0].creationTime;
before = this.courses[len - 1].creationTime;
}
let subscription = this.courseAdminService.get(since, before, this.keyword)
.subscribe(courses => {
this.courses = this.courses.concat(courses);
subscription.unsubscribe();
});
}
}
And I have the following interface:
export interface Course {
id: string;
nameEn: string;
nameAr: string;
trainer: string;
type: string;
country: string;
city: string;
level: string;
creationTime: Date;
}
The problem here is that when I try to compile the app (using angular@cli) it gives me the error: Property 'creationTime' does not exist on type 'Course'
, and as you can see above the creationTime
property is indeed a part of the interface. So can anybody tell me whats the issue here?
Upvotes: 1
Views: 954
Reputation: 1121
It turned out that whenever I want to modify an interface like adding a new property or even create a new interface, I have to stop the ng serve
command and rerun it again.
Upvotes: 2