我通过了this,并了解到在声明了数据绑定的输入属性之后,Angular应该自动更新输入值。在我创建的组件中,似乎并非如此。
当我单击父级网格上的项目时,它会正确显示详细信息。之后,当我单击另一个项目时,它不会更新子组件。我放置了console.log来监视所选记录。它会根据用户选择不断变化。
您能否看一下,并帮助我了解问题所在?
listing.component.html [父母]
<div class="container-fluid">
<div class="row mt-2 mb-2">
<div class="col-8">
<app-list-item-add *ngIf="showAddnewScreen" (notifyParentOnUpdate)='onAddItem($event)'></app-list-item-add>
<app-list-item-view *ngIf="showViewScreen" [studentObject]="selectedstudent" (notifyParentOnUpdate)='onViewItem($event)'></app-list-item-view>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
list.component.ts [父母]
import { Component, OnInit, ViewChild } from '@angular/core';
import { studentsService, student } from '../services/students.service';
import { Router, ActivatedRoute } from '@angular/router';
import { GridComponent, ToolbarItems, SortEventArgs, RowSelectEventArgs, SelectionSettingsModel } from '@syncfusion/ej2-ng-grids';
import { ClickEventArgs } from '@syncfusion/ej2-ng-navigations';
import * as moment from 'moment';
import { Internationalization } from '@syncfusion/ej2-base';
@Component({
selector: 'app-lists', …
Run Code Online (Sandbox Code Playgroud) data-binding parent-child typescript angular two-way-binding