Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2.  
  3. @Component({
  4. selector: 'app-user-list',
  5. templateUrl: './user-list.component.html',
  6. styleUrls: ['./user-list.component.scss']
  7. })
  8. export class UserListComponent implements OnInit {
  9. names: any ;
  10.  
  11.  
  12. constructor() {
  13. this.names = [{title:'Ari'},{title:'Carlos'},'Felipe','Nate'];
  14. }
  15.  
  16. ngOnInit() {
  17. }
  18.  
  19. }
  20.  
  21. import { Component, OnInit, Input } from '@angular/core';
  22.  
  23. @Component({
  24. selector: 'app-user-item',
  25. templateUrl: './user-item.component.html',
  26. styleUrls: ['./user-item.component.scss']
  27. })
  28. export class UserItemComponent implements OnInit {
  29.  
  30. @Input() name: any;
  31.  
  32. constructor() {
  33.  
  34.  
  35.  
  36. }
  37.  
  38. ngOnInit() {
  39. }
  40.  
  41. }
  42.  
  43. <ul>
  44. <li *ngFor="let name of names">
  45. <app-user-item [name] = "name"></app-user-item>
  46. </li>
  47. </ul>
  48.  
  49. <h1>
  50. Hello {{name.title}}
  51. </h1>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement