I am using tslint to check my angular 2 project and am getting some errors that I don't really understand. The following code snippit gets a "expected an assignment or function call"-error, but isn't that exactly what my code is doing?
getUsers() {
this._userService.getUsers().subscribe(data => {
this.userList = data.users,
this.number_of_pages = data.number_of_pages,
this.number_of_users = data.number_of_users;
});
}
Is this a bug or do I not understand the error correctly? I am using typescript version 1.8.10.
Edit: The error occures at the first assignment, so this.userList = data.users
I think the problem is that you don't use semi-colons but comma at the end of two lines:
this.userList = data.users, // <----
this.number_of_pages = data.number_of_pages, // <----
this.number_of_users = data.number_of_users;
You should use the following:
this.userList = data.users; // <----
this.number_of_pages = data.number_of_pages; // <----
this.number_of_users = data.number_of_users;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.