Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度4动态加载模板URL_Angular_Typescript - Fatal编程技术网

Angular 角度4动态加载模板URL

Angular 角度4动态加载模板URL,angular,typescript,Angular,Typescript,我在.net框架中有一个小部件,我想调用与Angle page中相同的小部件,但我不想使用iframe 为此,我用razor引擎和返回计划HTML编译此页面,并在angular project中写入HTML,我想在angular 4应用程序中显示此页面。请帮助我以任何方式在angular 4应用程序中显示此类型的ho HTML页面 我想将动态创建的html页面显示为角度组件 这是我尝试创建动态模板URL的代码 这里我称之为html模板 生成角度应用程序moduleId的类型出错:找不到modul

我在
.net
框架中有一个小部件,我想调用与Angle page中相同的小部件,但我不想使用iframe

为此,我用razor引擎和返回计划HTML编译此页面,并在angular project中写入HTML,我想在angular 4应用程序中显示此页面。请帮助我以任何方式在angular 4应用程序中显示此类型的ho HTML页面 我想将动态创建的html页面显示为角度组件 这是我尝试创建动态模板URL的代码

这里我称之为html模板 生成角度应用程序moduleId的类型出错:找不到module.id 当我删除moduleId:module.id时 如何解决此问题

尝试以下方法:

ngAfterViewInit() {

    const template = '<span>generated on the fly: {{name}}</span>';

    const tmpCmp = Component({ template: template })(class {
    });
    const tmpModule = NgModule({ declarations: [tmpCmp] })(class {
    });

   this.compiler.compileModuleAndAllComponentsAsync(tmpModule)
      .then((factories) => {
        const f = factories.componentFactories[0];

        const cmpRef = this.vc.createComponent(f);

        cmpRef.instance.name = 'dynamic';
      }); 
  }
ngAfterViewInit(){
常量模板='动态生成:{{name}}';
const tmpCmp=组件({template:template})(类{
});
const tmpModule=NgModule({declarations:[tmpCmp]})(类{
});
this.compiler.compileModuleAndAllComponentsAsync(tmpModule)
.然后((工厂)=>{
常数f=工厂。组件工厂[0];
const cmpRef=this.vc.createComponent(f);
cmpRef.instance.name='dynamic';
}); 
}

请不要放置文本图像。阅读和复制您的问题会更加困难。。。