Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ..//
- import {Http, HTTP_PROVIDERS} from 'angular2/http';
- @Component({
- viewProviders: [HTTP_PROVIDERS],
- template: `
- ..//
- <div class="col-md-6 col-md-offset-3 well">
- <input type="button" class="btn btn-success btn-block"
- (click)="get()" value="Fetch Users">
- <hr>
- <ul>
- <li *ngFor="#user of users">
- Id: {{ user.name }} | Name: {{ user.name }} | JSON: {{ user | json }}
- </li>
- </ul>
- </div>
- ..//
- export class Mov {
- //Inicio test http
- users: Array<Object>;
- http: any;
- //
- //constructor(@Inject(HttpFactory) http) {
- //constructor(http: Http) {
- constructor(http: Http){
- //
- this.http = http;
- }
- get(){
- this.http('resources/users.json')
- .map(res => res.json())
- .subscribe(users => this.users = users);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement