问题 什么是在对应的模板元素显示后获取 @ViewChild 最优雅的方法? 以下是一个示例。还有一个可用的Plunker。 Component.template.html:<div id="layout" *ngIf="display"> ...
我该如何配置新的 Angular 8 视图子组件?@ViewChild('searchText', {read: ElementRef, static: false}) public searchTextInput: ElementRef; 对比@ViewChild('searchText',...
当我尝试使用ViewChild时,我遇到了错误。错误信息是“未提供'opts'的参数。” 无论是@ViewChild都会产生错误。 import { Component, OnInit, ElementRef, ViewChild, Output, EventEmitter } from ...
我试图访问一个本地元素,以便在单击另一个元素时将其聚焦(就像html属性“for”一样-不能用于此类型的元素)。但是我收到错误:类型错误:无法读取未定义的“nativeElement”属性我尝试在ngAfterViewInit()中打印nativeElement,以便它被加载,但仍会抛出错误。...
我正在尝试更新Angular表中使用的数据后刷新该表。文档中说“您可以通过调用其renderRows()方法来触发对表呈现行的更新。”但是,这不像一个普通的子组件,我无法使用类似“@ViewChild(MatSort) sort: MatSort;”的东西,因为我没有导入它。 如果我导入它并...
我之前是这样使用ViewChild的:@ViewChild("InternalMedia") localStream; @ViewChild("emoji") mEmoji; 在升级到angular-8.x之前,一切都运行良好。 但是一旦我升级到angular-8.x,就开始出现以下错误:....
我查看了几篇相关的帖子和文档,但似乎仍然无法从@ViewChild中获得预期的行为。 最终,我想要设置一个div的滚动位置。这个元素不是一个组件,而是在我的HTML中的普通div。 为了实现这一点,我尝试使用@ViewChild来获取我需要的DOM元素,并设置其滚动值。(顺便说一句,如果您...
我想要访问一个ViewChildren QueryList的第n个子元素。 以下是我的TS代码:@ViewChildren(PopoverDirective) popovers: QueryList<PopoverDirective>; console.log(this.popo...
我正在使用 Angular 5.2.0。我有一个子组件。import { Component } from '@angular/core'; @Component({ template: `<div><div></div></div>`, ...
由于某些原因,我的 Angular 5 应用中的 @ViewChild 无法正常工作。 我在组件中像这样进行了定义: case-detail.component.html:<div class="inner-tab-content" #innerTabContent&...