0

I am developing nativescript-angular app that contains dataform in a module and calling this module using in lazy loading technique. Life is beautiful in Android, but the application exits immediately when I open this module in ios wihtout any error log! The code is very simple and forward, I can't see where is the problem!

test.component.ts

import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { RadDataForm, DataFormEventData } from "nativescript-ui-dataform";
import { UserAddress } from "../../shared/data-services/address";
@Component({
    selector: "test",
    moduleId: module.id,
    templateUrl: "./test.component.html",
    styleUrls:["./test.component.css"]
})
export class TestComponent implements OnInit {
    private _userAddress: UserAddress;
    constructor() {
     } 
    ngOnInit() {
        this._userAddress = new UserAddress();
    }
    get userAddress(): UserAddress {
        return this._userAddress;
    }
}

test.component.html

<ActionBar class="action-bar">
        <NavigationButton [nsRouterLink]="['../../home']" android.systemIcon="ic_menu_back"></NavigationButton>
        <Label class="action-bar-title" text="Test"></Label>
</ActionBar>
<ScrollView tkExampleTitle tkToggleNavButton>
    <StackLayout>
        <RadDataForm tkExampleTitle tkToggleNavButton [source]="userAddress">
        </RadDataForm>
    </StackLayout>
</ScrollView>

Routing of this module signup-routing.module.ts

import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";


import { ItemsComponent } from "./test/test.component";


export const COMPONENTS = [ItemsComponent ];

const routes: Routes = [

    { path: "", redirectTo: "testInfo"  },
    { path: "testInfo", component: testComponent }
];

@NgModule({
    imports: [NativeScriptRouterModule.forChild(routes)],  // set the lazy loaded routes using forChild
    exports: [NativeScriptRouterModule]
})
export class SignupRoutingModule {}

Then we have signup.module.ts

import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptCommonModule } from "nativescript-angular/common";
import { COMPONENTS, SignupRoutingModule } from "./signup-routing.module";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NativeScriptUIDataFormModule } from "nativescript-ui-dataform/angular";


@NgModule({
    imports: [
       NativeScriptCommonModule, // for rednering actionbar with lazy laoding
       NativeScriptFormsModule,
       SignupRoutingModule,
       NativeScriptUIDataFormModule

    ],
    declarations: [
        ...COMPONENTS
    ],
   // providers: [SignupService],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
/*
Pass your application module to the bootstrapModule function located in main.ts to start your app
*/
export class SignupModule { }

And the module is called using lazy loading in the basic routing file like this:

{ path: "signup", loadChildren: "~/app/signup/signup.module#SignupModule", outlet: "homeTab"  } 

Help is appreciated! CODE ON GitHub https://github.com/lighttiger/lazy

  • Just trying to understand the issue, does it work if you comment out the `RadDataForm` in the template? – Manoj Jan 15 '19 at 17:04
  • Please, the project is stopped because of this issue on IOS! anybody has any ideas?! – Light Tiger Jan 15 '19 at 22:12
  • Yes, off course, it works when I comment the RadDataForm in the template – Light Tiger Jan 15 '19 at 22:13
  • Did you try cleaning up the directives `tkExampleTitle tkToggleNavButton`, unless you them defined in your app. – Manoj Jan 15 '19 at 22:19
  • I tried cleaning up the directives, and still not working on ios, the app exists on this template! – Light Tiger Jan 16 '19 at 16:05
  • Can you try uploading the sample to Gtihub and share? – Manoj Jan 16 '19 at 16:13
  • I uploaded code on github https://github.com/lighttiger/lazy – Light Tiger Jan 17 '19 at 23:59
  • I don't think lazy loading is the problem here, `RadDataForm` doesn't work at all in the project you have posted, even if it's used in app module. Not exactly sure why. But simply creating a new project with `tns create` and placing your module / components within works. You might want to compare your project with starter template and see what you are missing Or simply use a fresh project template. – Manoj Jan 18 '19 at 17:33
  • I have already isolated the problem and put it in a starter template project, I have a lazy loading module that contains a RadDataForm and it is working fine on Android but always causing the app to exit on IOS. I realized that the combination of Lazy loaded module with RadDataForm inside it won't work on IOS and That is what I am asking about – Light Tiger Jan 19 '19 at 00:46
  • I don't think so, because it works just fine with Playground or on a new local project - Lazy Loaded + RadDataForm. With your project template, even if I move the code to app module, it still use to crash. – Manoj Jan 19 '19 at 04:49
  • Okay, I need to know what is the problem in my code to solve it! – Light Tiger Jan 19 '19 at 15:06

0 Answers0