I have several classes that I would like to include in a module, so I can then just import the module, as it was a different package, and use those classes from it. Here's a small example:
human.ts (my class file)
export class Human {
private numOfLegs: Number;
constructor() {
this.numOfLegs = 2;
}
}
test.module.ts (my module file)
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Human } from './human';
@NgModule({
imports: [CommonModule],
declarations: [
Human
],
providers: [],
exports: [Human]
})
export class TestModule {}
How do I instantiate the Human class in a component? I've tried both:
import { TestModule } from './test.module';
and
import { Human } from './test.module';
But if I do new Human()
I still get cannot find name Human