Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1.  
  2. export class EmployeeService {
  3.  
  4. employees : AngularFireList<Employee>;
  5. Employee : AngularFireObject<any>;
  6.  
  7. constructor( public af : AngularFireDatabase) {
  8. this.employees = this.af.list<Employee>('/employees/employees');
  9. }
  10. getEmployees()
  11. {
  12. return this.employees.valueChanges();
  13. }
  14. }
  15. *Heres employee component : *
  16. employees:Employee[];
  17. constructor(public employeeService : EmployeeService) {
  18.  
  19. }
  20.  
  21. ngOnInit() {
  22. this.employeeService.getEmployees().subscribe(employees=>{
  23. this.employees=employees;
  24. console.log(this.employees);
  25. });
  26. }
  27. Heres the employee.html:
  28. <tr *ngFor="let item of employees">
  29.  
  30. <th >{{item.firstName}}</th>
  31. <th >{{item.lastName}}</th>
  32. <th >{{item.email}}</th>
  33. <th >{{item.country}}</th>
  34. <th >{{item.city}}</th>
  35. <th >{{item.phone}}</th>
  36. <th >{{item.salary}}</th>
  37. <th >{{item.$key}}</th>
  38.  
  39.  
  40. </tr>
  41. any one is having an idea?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement