Guest User

Untitled

a guest
Mar 24th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import { Component } from '@angular/core'
  2.  
  3. @Component({
  4. selector: 'app-root',
  5. templateUrl: './app.component.html'
  6. })
  7.  
  8. export class AppComponent {
  9.  
  10. courses = [
  11. {id:1, name:'Course 1'},
  12. {id:2, name:'Course 2'},
  13. {id:3, name:'Course 3'}
  14. ]
  15.  
  16. viewMode = 'map';
  17.  
  18. canSave = true;
  19.  
  20. onAdd() {
  21. this.courses.push({id:4, name:'Courses 4'});
  22. }
  23.  
  24. onRemove(course) {
  25. let index = this.courses.indexOf(course);
  26. this.courses.splice(index, 1);
  27. }
  28.  
  29. loadCourses () {
  30. this.courses.push({id:4, name:'Course 4'});
  31. }
  32.  
  33. // for better performace
  34. trackCourses(index, course) {
  35. return course ? course.id : undefined;
  36. }
  37. }
Add Comment
Please, Sign In to add comment