Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- goalText: string = 'Это моя новая запись';
- commentText = ['Это мой новый комментарий'];
- goals: string[];
- comments = ['Первый'];
- arrcom = [this.goals, this.comments];
- ngOnInit() {
- this._data.goal.subscribe(res => this.goals = res);
- this.itemCount = this.goals.length;
- this._data.changeGoal(this.goals);
- this.comcount = this.comments.length;
- }
- addItem() {
- this.goals.push(this.goalText);
- this.goalText = '';
- this._data.changeGoal(this.goals);
- this.itemCount = this.goals.length;
- }
- addComment(i) {
- this.arrcom[i].push(this.commentText[i]);
- this.commentText[i] = 'Комментарий';
- this.comcount = this.arrcom[i].length;
- }
- <div class="container color-light" [@goals]="goals.length">
- <div class="col">
- <p class="sm">Форма для ввода записи</p>
- <form>
- <input type="text" class="txt" name="item" placeholder="Введите Вашу запись здесь" [(ngModel)]="goalText" />
- <input type="submit" class="btn" [value]="btnText" (click)="addItem()" />
- </form>
- </div>
- <div class="col">
- <!-- -->
- <div ng-scroller>
- <div class="life-container" *ngFor="let goal of goals, let i = index" [attr.data-n]="i">
- <p>
- {{i+1}}) {{ goal }}
- </p>
- <form class="commentarii">
- <input type="text" class="txtcomment" name="item" placeholder="Ваш комментарий" [(ngModel)]="commentText[i]" />
- <input type="submit" class="btnComment" [value]="btnCommentText" (click)="addComment(i)" />
- </form>
- <p class="life-container-com" *ngFor=" let comment of arrcom[i], let j = index,">
- {{ comment }}
- </p>
- </div>
- </div>
- </div>
- </div>
Add Comment
Please, Sign In to add comment