Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.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
Javascript 导入的模块绑定不适用于Angular 7中创建的DOM元素_Javascript_Html_Angular_Ionic Framework - Fatal编程技术网

Javascript 导入的模块绑定不适用于Angular 7中创建的DOM元素

Javascript 导入的模块绑定不适用于Angular 7中创建的DOM元素,javascript,html,angular,ionic-framework,Javascript,Html,Angular,Ionic Framework,在我的项目home.page.ts中,我有一些代码,可以在编译后通过id为的div在HTML上创建一个标记元素 e、 g:this.video=document.createElement('video')//将在HTML中创建标记 此外,我还在app.module.ts中导入了一个模块NgxFaceApiJsModule,它可以绑定到HTML标记中的属性中,并生成检测输出 在我的HTML中,如果我直接使用,它将工作并给出输出。但是,如果使用(稍后将替换为after compiled),它将不起

在我的项目
home.page.ts
中,我有一些代码,可以在编译后通过id为
的div在HTML上创建一个
标记元素

e、 g:
this.video=document.createElement('video')//将在HTML中创建标记

此外,我还在
app.module.ts
中导入了一个模块NgxFaceApiJsModule,它可以绑定到HTML标记中的属性中,并生成检测输出

在我的HTML中,如果我直接使用
,它将工作并给出输出。但是,如果使用
(稍后将替换为after compiled),它将不起作用。我怎样才能解决这个问题

home.page.ts app.module.ts home.page.html
使用界面
AfterViewInit

类HomePageComponent实现AfterViewInit{
@ViewChild(“videoContainer”)videoContainer;
私人视频:HTMLVideoElement;
建造师(
public facedetect:NgxFaceApiJsModule,
) {
}
ngAfterViewInit():void{
this.video=document.createElement('video');
this.video.setAttributeNS(null,'allFaces','';
this.video.setAttribute('autoplay','');
this.video.height=480;
this.video.width=640;
this.facedetect.detecttallfaces(this.video);
}
}

然后您应该向我们展示将html插入到div@Ramesh很抱歉,因为我之前很忙,现在添加了home.page.htmltried在ngAfterViewInit()中实现了它,但仍然无法使其工作。没有Detection的输出我猜您添加了一行:facedetect.detectAllFaces(this.video)。我用这一行编辑答案。添加facedetect.DetectalFaces(this.video)也不起作用,因为NgxFaceApiJsModule中不存在该属性。这是我在这里使用的模块的链接。如果我没有在构造函数中声明它,它也会运行。它将检测并产生img或视频标签输出。但在我的情况下,没有工作。

  @ViewChild('videoContainer') videoContainer;

  private video: HTMLVideoElement;

  constructor(
    public facedetect: NgxFaceApiJsModule,
  ) {

    this.video = document.createElement('video');
    this.video.setAttributeNS(null, 'allFaces', '');
    this.video.setAttribute('autoplay', '');
    this.video.height = 480;
    this.video.width = 640;
  }

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), NgxFaceApiJsModule.forRoot({ modelsUrl: 'https://raw.githubusercontent.com/justadudewhohacks/face-api.js/master/weights',}), AppRoutingModule],
  providers: [
    MediaCapture,
    StatusBar,
    SplashScreen,
    AndroidPermissions,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}
<ion-content>
  <div #videoContainer></div>
</ion-content>