调用Ajax调用我有这个组件:为什么我无法从Angular2
import {Component} from 'angular2/core';
import {UserServices} from '../services/UserServices';
@Component({
selector: 'users',
template: '<h1>HOLA</h1>'
})
export class UsersComponent {
users: Object;
constructor(userServices: UserServices) {
userServices.getUsersList();
}
}
,并在UserServices我有这样的代码:
import {Http} from 'angular2/http'
export class UserServices {
users: Array<any>;
http: any;
constructor(http: Http) {
this.http = http;
}
getUsersList() {
this.http.get('./users.json').map((res: Response) => res.json()).subscribe(res => console.log(res));
}
}
我要调用一个Ajax调用的users
定制标签。 但我发现了这个错误:
Cannot resolve all parameters for UserServices(?). Make sure they all have valid type or annotations.
当我删除HTTP参数,进口和调用,它没有任何错误,所以我想这个问题是存在的,但我不能找出问题
完美!非常感谢! – Pablo
@Pablo欢迎您。 :) – PSL
@PSL我有一个问题不涉及这个问题,如果你不介意。 “你多次使用'''''''我的意思是你为什么使用'Array'而不是'IUser []'?它是如何调用的,以及我可以在哪里了解更多信息? –
Eggy