我从2天开始诚心诚意地搜索,试图解决这个问题,因为缺乏知识。我最近才开始学习Nativescript,对Angular也有一定的了解。
ShopInfosComponent
在我 map.component.ts
: const options: ModalDialogOptions = {
viewContainerRef: this.viewContainerRef,
fullscreen: false,
context: {},
};
this.modalService.showModal(ShopInfosComponent, options);
ShopInfosComponent
属于 BrowseModule
我知道我需要把它添加到
@NgModule({
imports: [
NativeScriptCommonModule,
BrowseRoutingModule,
],
declarations: [
BrowseComponent,
MapComponent,
ShopInfosComponent
],
entryComponents: [ShopInfosComponent]
})
浏览模块属于上层模块 AppModule
.
模式 ShopInfosComponent
成功地按照意图打开,但有 无数据绑定实际上 ngOnInit
不叫 与构造函数不同)。
这就是模式的内容 shop-infos.component.html
:
<StackLayout>
<Label [text]="result"></Label>
<Label text="Static Text"></Label>
</StackLayout>
我试着直接在里面打开一个模态 AppModule
随着 app.component.ts
这很奇怪的工作!它只是在放在另一个模块中时不工作,而这个模块是由它导入的。AppModule
.
使用的app模板是 导航抽屉 的Nativescript。
也许是懒加载应用路由的问题?
我已经在我的网站上上传了应用程序的图形文档和源代码。https:/luiswillnat.eustacknativescriptdatabinding。
请大家放心使用,我真的很愿意找到解决的办法,并从中学习。
正如 @Lasanga Guruge 在评论中提到的,这是一个... 当期 的 nativescript-angular
.
目前在模式视图中进行数据绑定和ngOnInit的工作方法是手动检测变化。
setTimeout(() => {
this.zone.run(() => this.result = "WORKING")
});
或者
setTimeout(() => {
this.changeDetectorRef.detectChanges();
});
是目前的变通办法。