Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public JsonResult Get()
  2. {
  3. string[] values = { "value1", "value2" };
  4. return Json(values);
  5. }
  6.  
  7. import {Component} from 'angular2/core';
  8. import {Http, Headers, Response} from 'angular2/http';
  9.  
  10. @Component({
  11. selector: 'file-system',
  12. templateUrl: './app/app.component.html'
  13. })
  14.  
  15. export class AppComponent {
  16. title: string;
  17. values: Array<string> = [];
  18.  
  19. constructor(public http: Http) {
  20. this.title = "File system";
  21. this.getData();
  22. }
  23.  
  24. getData() {
  25.  
  26. this.http.get('api/Values')
  27. .map((res: Response) => res.json())
  28. .subscribe(
  29. data => { this.values = data },
  30. err => console.error(err),
  31. () => console.log('done')
  32.  
  33. );
  34. }
  35.  
  36. generateArray(obj) {
  37. return Object.keys(obj).map((key) => { return obj[key] });
  38. }
  39. }
  40.  
  41. <h1>{{ title }}</h1>
  42. <div>Hello ASP.NET Core! Greetings from AngularJS 2.</div>
  43.  
  44. <h3 style="color:#C70039;">
  45. <span *ngFor="let stdArray of values"> {{stdArray}} </span>
  46. </h3>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement