I'm new at angular2 and I'm trying to get data from web api with my angular2 application. I'm using Visual Studio 2015. I have no error but the datas just don't display, I should get all the users Login display on my html page but it's empty, it shows the right number of existing Logins though, here's the result :
my component :
import { Component } from "@angular/core";
import { Http, Response } from "@angular/http";
@Component({
selector: "team",
templateUrl: "../Scripts/components/team/team.component.html"
})
export class TeamComponent {
public users: IUserID[];
private _userIdUrl = "http://localhost:61142/api/UserID";
constructor(private http: Http) {
http.get(this._userIdUrl).subscribe(result => {
this.users = result.json();
});
}
}
interface IUserID {
Login: string;
}
and my controller :
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class UserIDController : ApiController
{
IUserIDBusiness userIDBusiness;
public UserIDController()
{
userIDBusiness = WebApiConfig.userIDBusiness;
}
public IEnumerable<UserID> Get()
{
return userIDBusiness.GetAll();
}
[EDIT] Html :
<ul>
<li *ngFor="let user of users">
{{ user.Login }}
</li>
</ul>
What am I missing ?
