Angular 2和systemjs:如何导入到将在运行时创建的app.module.ts文件中?
考虑一个具有可重用angular 2组件的项目。现在在运行时,我将组件文件复制到另一个项目中,以便能够使用它们。应该怎么做 第一个问题是.ts无法识别文件路径,它实际上不存在,将在运行时存在Angular 2和systemjs:如何导入到将在运行时创建的app.module.ts文件中?,angular,typescript,systemjs,Angular,Typescript,Systemjs,考虑一个具有可重用angular 2组件的项目。现在在运行时,我将组件文件复制到另一个项目中,以便能够使用它们。应该怎么做 第一个问题是.ts无法识别文件路径,它实际上不存在,将在运行时存在 import { HelloComponent } from 'my-framework/components/hello/hello.component.ts'; 这个导入似乎有效,altouge.ts无法识别URL,但在加载时他找到了文件。现在我在那个文件本身上出错了,我不理解。如何将文件编译到项目中
import { HelloComponent } from 'my-framework/components/hello/hello.component.ts';
这个导入似乎有效,altouge.ts无法识别URL,但在加载时他找到了文件。现在我在那个文件本身上出错了,我不理解。如何将文件编译到项目中
import { Component } from '@angular/core';
@Component({
selector: 'hello',
template: `<h1>Hello {{name}}</h1>`
})
export class HelloComponent { name = 'You'; }
从'@angular/core'导入{Component};
@组成部分({
选择器:“你好”,
模板:`Hello{{name}}`
})
导出类HelloComponent{name='You';}
是否有人创建了一个包含组件的项目,并将它们插入到另一个项目中并能够使用它们?我想我不明白它是如何完成的。在app.module.ts文件中,确保声明组件: `````
`````在app.module.ts文件中,确保声明组件: ````` `````
import { HelloComponent } from 'my-framework/components/hello/hello.component';
@NgModule({
declarations: [
MyApp,
HelloComponent
]