Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Ngonit和数据绑定在ModalView NativeScript中不起作用_Angular_Typescript_Modal Dialog_Nativescript_Nativescript Angular - Fatal编程技术网

Angular Ngonit和数据绑定在ModalView NativeScript中不起作用

Angular Ngonit和数据绑定在ModalView NativeScript中不起作用,angular,typescript,modal-dialog,nativescript,nativescript-angular,Angular,Typescript,Modal Dialog,Nativescript,Nativescript Angular,我从2天开始真诚地搜索,并试图解决由于缺乏知识而导致的问题。我最近开始使用Nativescript,我是Angular的中级用户 问题 我正试图在我的map.component.ts中打开模式ShopInfosComponent: ShopInfosComponent属于BrowseModule,我知道我需要将其添加到该模块中 @NgModule({ imports: [ NativeScriptCommonModule, BrowseRoutingM

我从2天开始真诚地搜索,并试图解决由于缺乏知识而导致的问题。我最近开始使用Nativescript,我是Angular的中级用户

问题
  • 我正试图在我的
    map.component.ts
    中打开模式
    ShopInfosComponent
ShopInfosComponent
属于
BrowseModule
,我知道我需要将其添加到该模块中

@NgModule({
    imports: [
        NativeScriptCommonModule,
        BrowseRoutingModule,
    ],
    declarations: [
        BrowseComponent,
        MapComponent,
        ShopInfosComponent
    ],
    entryComponents: [ShopInfosComponent]
})

浏览器模块属于上层模块
AppModule

真正的问题: 模式
ShopInfosComponent
按预期成功打开,但没有数据绑定,实际上
ngOnInit
未被调用(与构造函数不同)

这是modal
shop infos.component.html
的内容:

<StackLayout>
    <Label [text]="result"></Label>
    <Label text="Static Text"></Label>
</StackLayout>


我试过的 我试着用
app.component.ts
直接在
AppModule
中打开一个模态,它工作起来很奇怪! 只有当放入另一个由
AppModule
导入的模块时,它才不起作用

使用的应用程序模板是来自Nativescript的

也许是延迟加载应用程序路由的问题

我已将应用程序图形文档和源代码上载到我的网站:

请随意使用,我真的很愿意找到解决方案并从中学习


正如@Lasanga Guruge在评论中提到的,它是一个
nativescript angular

在模态视图中使用数据绑定和ngOnInit的当前解决方法是手动检测更改

setTimeout(() => {
   this.zone.run(() => this.result = "WORKING")
});


是目前的解决办法。

试着手动运行changeDetection(解决办法)。这可能有助于了解正在发生的事情。我已经看到了讨论,似乎来自那里,代码终于工作了,非常感谢:D!
setTimeout(() => {
   this.zone.run(() => this.result = "WORKING")
});
setTimeout(() => {
   this.changeDetectorRef.detectChanges();
});