Guest User

Untitled

a guest
Sep 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. goalText: string = 'Это моя новая запись';
  2. commentText = ['Это мой новый комментарий'];
  3. goals: string[];
  4. comments = ['Первый'];
  5. arrcom = [this.goals, this.comments];
  6. ngOnInit() {
  7. this._data.goal.subscribe(res => this.goals = res);
  8. this.itemCount = this.goals.length;
  9. this._data.changeGoal(this.goals);
  10. this.comcount = this.comments.length;
  11. }
  12. addItem() {
  13. this.goals.push(this.goalText);
  14. this.goalText = '';
  15. this._data.changeGoal(this.goals);
  16. this.itemCount = this.goals.length;
  17. }
  18. addComment(i) {
  19. this.arrcom[i].push(this.commentText[i]);
  20. this.commentText[i] = 'Комментарий';
  21. this.comcount = this.arrcom[i].length;
  22. }
  23.  
  24. <div class="container color-light" [@goals]="goals.length">
  25. <div class="col">
  26. <p class="sm">Форма для ввода записи</p>
  27. <form>
  28. <input type="text" class="txt" name="item" placeholder="Введите Вашу запись здесь" [(ngModel)]="goalText" />
  29.  
  30. <input type="submit" class="btn" [value]="btnText" (click)="addItem()" />
  31.  
  32. </form>
  33. </div>
  34. <div class="col">
  35. <!-- -->
  36. <div ng-scroller>
  37. <div class="life-container" *ngFor="let goal of goals, let i = index" [attr.data-n]="i">
  38. <p>
  39. {{i+1}}) {{ goal }}
  40. </p>
  41.  
  42. <form class="commentarii">
  43.  
  44. <input type="text" class="txtcomment" name="item" placeholder="Ваш комментарий" [(ngModel)]="commentText[i]" />
  45. <input type="submit" class="btnComment" [value]="btnCommentText" (click)="addComment(i)" />
  46. </form>
  47. <p class="life-container-com" *ngFor=" let comment of arrcom[i], let j = index,">
  48. {{ comment }}
  49. </p>
  50. </div>
  51.  
  52. </div>
  53. </div>
  54. </div>
Add Comment
Please, Sign In to add comment