I face a problem while trying to export a class which is under a module to another module. The problem is there was an error saying that the imported module is not a module.
Here is the module
/// <reference path="sensor_location.ts" />
module LATS.DataModel {
export class _RegistrationHelper {
static register(metadataStore) {
metadataStore.registerEntityTypeCtor('sensor_location', LATS.DataModel.sensor_location);
}
}
}
Here is my import
import {_RegistrationHelper} from '../entities/_RegistrationHelper';
Then I proceed to removed the module before the class, but another error came out
Error: Uncaught (in promise): ReferenceError: LATS is not defined
My question is is it correct to remove the module in order to export the class or there is another way to import the module? I've tried to add an export before the module but an error came up saying that the module has no exported member
A module has another purpose in the Angular-Framework. It's wrong and not working to define classes in a module that you want import elsewhere in the system.
The helper-class you defined has to be put in a separate file or service.
e.g.
helper-classes.ts
export class _LoginHelper {
// ...
}
export class _RegistrationHelper {
static register(metadataStore) {
metadataStore.registerEntityTypeCtor('sensor_location', LATS.DataModel.sensor_location);
}
}
//...
Or
helper.service.ts
//... Service-Header and imports
public login(user) {
//...
}
public register(metadataStore) {
metadataStore.registerEntityTypeCtor('sensor_location', LATS.DataModel.sensor_location);
}
}
Then import the class out of the TS-File or use the method out of a service wherever you need the method.