- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Angular 10 应用程序中,我正在通过组件工厂解析器加载一个包含 AG 网格的组件。
当我通过按钮触发工厂解析器时,一切正常。显示网格和 gridReady
事件被正确触发。
但是,如果我通过 ngOnInit()
触发组件工厂解析器或 ngAfterViewInit()
等,不触发gridReady事件,不显示网格。
我尝试使用 ChangeDetectorRef 服务来强制更改检测,但这并没有改变任何东西。
这是组件工厂解析器的代码:
export class PlannerComponent implements OnInit {
@ViewChild('ordersContainer', {read: ViewContainerRef}) container: ViewContainerRef;
public orders = [];
constructor(
private componentFactoryResolver: ComponentFactoryResolver,
private httpClient: HttpClient
) { }
ngOnInit(): void {
this.loadOpenOrders();
}
loadOpenOrders() {
this.httpClient.get('/orders')
.pipe(map((result: any) => {
const orders = result._embedded.orders;
orders.forEach((function (order) {
this.addOrder();
}).bind(this))
}))
.subscribe()
}
onGridReady(params) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
this.gridApi.sizeColumnsToFit();
}
addOrder() {
// Create component dynamically inside the ng-template
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(OrderComponent);
const newOrder = this.container.createComponent(componentFactory);
// Push the component so that we can keep track of which components are created
this.orders.push(newOrder);
}
}
在 View 中,组件是这样加载的:
<div class="container">
<div class="row">
<div class="col-6">
<div class="card card-custom gutter-b">
<ag-grid-angular
style="width: 100%; height: 600px;"
class="ag-theme-alpine"
[rowData]="ordersToPlan"
[columnDefs]="columnDefs"
[rowSelection]="rowSelectionType"
(gridReady)="onGridReady($event)" <==== Only triggered through button click, but not on ngOnInit()
[animateRows]="true"
>
</ag-grid-angular>
</div>
</div>
<div class="col-6">
<button class="btn btn-success mb-5" (click)="addOrder()">Add a new Order</button>
<div>
<ng-template #ordersContainer>
</ng-template>
</div>
</div>
</div>
</div>
任何帮助表示赞赏:-)
最佳答案
我终于找到了问题所在。我需要强制更改检测,但在子组件中(我通过组件工厂解析器加载的那个)。
在 order.component.ts
:
constructor(
private cd: ChangeDetectorRef
) { }
...
setTransport(transport: Transport): void {
...
this.cd.detectChanges();
}
非常感谢所有试图解决这个问题的人!
关于angular - AG 网格 : gridReady event not triggered when loading grid in a component via ComponentFactoryResolver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64771587/
我的应用程序中有大约 100 多个表。大多数更新查询不会更新最后更新的时间列。有 100 多个查询,所以我有点怀疑修改所有查询以包括上次更新时间。我正在寻找的替代选项是为所有表创建一个 oracle
我的应用程序中有大约 100 多个表。大多数更新查询不会更新最后更新的时间列。有 100 多个查询,所以我有点怀疑修改所有查询以包括上次更新时间。我正在寻找的替代选项是为所有表创建一个 oracle
trigger.io 是否支持黑莓?如果没有,是否有任何计划支持它。 最佳答案 在移动方面,他们目前支持: iOS 4+ (iPhone 和 iPad) 安卓 2.0+ window 电话* 我不知道
这是 here 中的一个改写的问题。经过一些测试后,我隔离了问题,但没有解决它的线索。无需阅读上一个问题,这是简化的代码: 问题 -> trigger('click')执行,但在循环(间隔)函数内时不
我有一个程序,它会从 redis 数据存储中轮询某个键,并在该值满足某个条件时执行某些操作。 不过我觉得redis周期性的轮询效率很低,想知道redis有没有“触发”机制,当值发生变化满足条件时,触发
现在我的合作者收到这样的错误:[错误] Forge API call to app/f7617c848[...]adcbe/should_rebuild 出错:应用匹配查询不存在。 最佳答案 我们正在
当用户在我的 trigger.io iOS 应用程序(使用 Parse.com)上收到推送通知并希望在用户打开应用程序时清除徽章时,我将徽章设置为 1。有谁知道如何做到这一点? 谢谢! 最佳答案 有几
iPhone 启动图像现在显示太短,我想延长持续时间。 有没有办法在 config.json 中指定它? 最佳答案 更新 :从平台版本 v1.4.20 开始,您可以控制启动图像的可见性(http://
如何将文件下载到我的 trigger.io 应用程序?我的应用程序显示离线数据,但我需要我的应用程序如何从服务器下载和存储本地新鲜数据的方式。数据是一个带有项目数组和一些图像的 js 文件,每个图像都
为了根据条件更改 ListBoxItem 前景,我可以通过 DataTemplate.Triggers 来完成: ...
为了根据条件更改 ListBoxItem 前景,我可以通过 DataTemplate.Triggers 来完成: ...
我们正在构建一个以 Chaplin 为基础的 Trigger 应用程序。出于开发目的,如果我们可以使用 Assets 的绝对路径,那就太好了,比如: 是否可以在 Trigger 中执行此操作?
什么时候应该选择Style.Triggers,什么时候应该选择ControlTemplate.Triggers?使用一个比另一个有什么好处吗? 假设我有实现相同结果的这些样式:
在我的情况下,我将有一个带有自定义 url 架构的重定向 URL,例如 myapp://oauth 所以首先我会转发到我的 oauth 登录 url,然后我需要为位置更改注册一个事件处理程序,以检查它
我可以创建一个带有 OR 条件的 MYSQL TRIGGER 创建或替换触发器 TIGGER 名称插入之前或更新或删除 像这样(下面是 ORACLE TRIGGER): CREATE OR REPLA
有两个相同类型但存在于不同类中的属性。 FrameworkElement.Triggers Property Style.Triggers Property 这让我很困惑,所以我很少有问题要寻找答案:
我有兴趣为 trigger.io 编写 native 插件。 这是否已经可能或在路线图上? 最佳答案 这绝对在路线图上:我们从一开始就不允许这样做的主要原因是我们最初的主要重点是创建一个尽可能平稳和快
我知道如何缓存它,但我以后如何检索它。文档 ( http://docs.trigger.io/en/v1.4/features/cache.html ) 仅给出了使用图像的示例,要检索您需要做的就是获
在 AzureFunction1 中收到简短通知后,我需要一种可靠的方法将其快速保存,然后触发另一个 Azurefunction 来分析数据并根据分析进行其他操作。 我正在寻找一种向 azure fu
我正在尝试使用 Trigger.io 的框架构建一个流式音频应用程序。 看到它的 API 目前没有任何与音频相关的方法,我用基本的 HTML5 audio 对其进行了测试。标签。在这种情况下流式传输
我是一名优秀的程序员,十分优秀!