我创建了一个新的 Angular 6 库。该库有一个名为 User 的模型:
export class User {
public id: string;
public username: string;
constructor(id: string,
username: string) {
this.id = id;
this.username = username;
}
}
我在另一个角度应用程序中使用该库,一切正常。但是当我尝试使用该模型时:
export class AppComponent {
public user: User;
constructor() {
this.user = new User('1', 'my user');
}
}
我收到此错误:
Module not found: Error: Can't resolve 'my-lib/lib/models/user.model' in 'C:\my-app\src\app'
智能感知找到了它,但我仍然收到此错误。
应用模块:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
UserModule,
],
bootstrap: [AppComponent]
})
有人有想法吗?谢谢!