0
votes

I am trying to do code sharing between angular web and mobile app using NativeScript Schematics. Here is my code structure

Code Structure

I have used [(ngModel)] in mobile specific HTML file and i have also imported NgFormsModule in my authentication.module.tns.ts which is NativeScript specific module file. However when i debug, i don't see NativeScriptFormsModule getting loaded. Also i am getting below error while running the app

Error: No value accessor for form control with unspecified name attribute

Here is my code of AuthenticationModule (authentication.module.tns.ts)

@NgModule({
  declarations: [
    ...componentDeclarations
  ],
  imports: [
    NativeScriptCommonModule,
    NativeScriptFormsModule,
    NativeScriptLocalizeModule,
    AuthenticationRoutingModule,
    ...importsDeclarations
  ],
  providers: [
  ],
  schemas: [NO_ERRORS_SCHEMA]
})
export class AuthenticationModule { }

Please note that my imports and declaration arrays are empty at this moment are created to take care of future imports.

One more strange issue that i have noticed with this is that if i import AuthenticationRoutingModule directly, then it gets loaded properly. However if i import it via importsDeclarations, it does not get loaded.

Similarly i am also using nativescript-localize plugin for localizing strings. I have created src/i18n/en.default.ts file. However i keep getting message that

'/project/src/i18n' is empty: nothing to localize

I even tried renaming file to en.default.tns.ts. However no luck. Both these issues look like the way nativescript-schematics load the files. Can someone please let me know on what is going wrong here?

EDIT

I did further debugging on this issue and looks like it is the issue due to webpack not able to load required modules. I have sample code at

https://github.com/phatakrajan/ns-codeshare-ui

1

1 Answers

0
votes

You will have to import NativeScriptFormsModule which will internally import NgFormsModule too.

Also the localised files should be JSON not TS,

src
  | i18n
      | en.json           <-- english language
      | fr.default.json   <-- french language (default)
      | es.js