Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. ..//
  2. import {Http, HTTP_PROVIDERS} from 'angular2/http';
  3.  
  4. @Component({
  5.  
  6. viewProviders: [HTTP_PROVIDERS],
  7.  
  8. template: `
  9. ..//
  10. <div class="col-md-6 col-md-offset-3 well">
  11. <input type="button" class="btn btn-success btn-block"
  12. (click)="get()" value="Fetch Users">
  13.  
  14. <hr>
  15. <ul>
  16. <li *ngFor="#user of users">
  17. Id: {{ user.name }} | Name: {{ user.name }} | JSON: {{ user | json }}
  18. </li>
  19. </ul>
  20. </div>
  21.  
  22. ..//
  23.  
  24. export class Mov {
  25.  
  26. //Inicio test http
  27.  
  28. users: Array<Object>;
  29. http: any;
  30.  
  31. //
  32. //constructor(@Inject(HttpFactory) http) {
  33. //constructor(http: Http) {
  34. constructor(http: Http){
  35. //
  36. this.http = http;
  37. }
  38.  
  39. get(){
  40. this.http('resources/users.json')
  41. .map(res => res.json())
  42. .subscribe(users => this.users = users);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement