Angular 4 DWT JavaScript库在模型中不起作用 [英] Angular 4 DWT JavaScript Library not working in model

查看:83
本文介绍了Angular 4 DWT JavaScript库在模型中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我想使用DWT Javascript库扫描我按照以下步骤操作的文档

但是在模型中使用相同的代码时,无法获得结果.

代码

 < ng-template #scanModal let-c ="close" let-d ="dismiss">< div class ="modal-header">< h6 class ="modal-title text-uppercase">扫描文档</h6>< button type ="button" class ="close指针" aria-label ="Close"(click)="d('Cross click'')">< span aria-hidden ="true"& times;</span></button></div>< div class ="modal-body">< button(click)="acquireImage()">扫描文档</button>< div id ="dwtcontrolContainer"></div></div>< span id =警告警报危险"& nbsp;</span>< div id ="info" style ="display:none; padding:20px 30px;宽度:350px;边框:实心1px#e7e7e7;">< strong> PDF Rasterizer</strong>未在此PC上安装< br/>请单击下面的按钮进行安装< p>< button(click)="downloadPDFR();">安装PDF Rasterizer</button></p>< i>< strong>安装是一次性过程</strong>< br/></i>可能需要一些时间,具体取决于您的网络.</div>< br/></div></ng-template> 

模型打开时出现此错误

RegisterComponent.html:376错误TypeError:无法读取null的属性"SelectSource"

我将HTML代码段粘贴到模型中的TS代码没有变化.

TS代码

  acquireImage():void {const dwObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');const bSelected = dwObject.SelectSource();如果(bSelected){const onAcquireImageSuccess =()=>{dwObject.CloseSource();};const onAcquireImageFailure = onAcquireImageSuccess;dwObject.OpenSource();dwObject.AcquireImage({},onAcquireImageSuccess,onAcquireImageFailure);}} 

谢谢.

解决方案

对于第一个问题,请查看其他帖子 dwt-java-script-library-progress-对话自动显示与角度5

对于第二个问题.如果似乎是由于缺少Types定义引起的.您在TS中添加了以下行吗?

///<引用类型="dwt"/>

Currently, I want use DWT Javascript library to scan the documents I followed these steps http://www.codepool.biz/javascript-global-library-angular-cli.html for a new project, it worked perfectly fine. When I try to incorporate into my main project I'm facing few issues like the progress bar model is will be present all the time no matter what happens.

but when using the same code inside the model, not able to get the result.

code

<ng-template #scanModal let-c="close " let-d="dismiss ">
   <div class="modal-header ">
      <h6 class="modal-title text-uppercase ">Scan Document</h6>
      <button type="button " class="close pointer" aria-label="Close " (click)="d( 'Cross click') ">
      <span aria-hidden="true ">&times;</span>
      </button>
   </div>
   <div class="modal-body">
      <button (click)="acquireImage()">Scan Document</button>
      <div id="dwtcontrolContainer"></div>
   </div>
   <span id="alert alert-danger">&nbsp; </span>
   <div id="info" style="display:none; padding:20px 30px; width: 350px; border: solid 1px #e7e7e7;">
      The <strong>PDF Rasterizer</strong> is not installed on this PC
      <br />Please click the button below to get it installed
      <p> <button (click)="downloadPDFR();">Install PDF Rasterizer</button></p>
      <i><strong>The installation is a one-time process</strong> <br />
      It might take some time depending on your network.</i>
   </div>
   <br/>
   </div>
</ng-template>

when the model opens I'm getting this error

RegisterComponent.html:376 ERROR TypeError: Cannot read property 'SelectSource' of null

there is no change in the TS code i just pasted HTML snippet into the model.

TS code

acquireImage(): void {
    const dwObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
    const bSelected = dwObject.SelectSource();
    if (bSelected) {
      const onAcquireImageSuccess = () => { dwObject.CloseSource(); };
      const onAcquireImageFailure = onAcquireImageSuccess;
      dwObject.OpenSource();
      dwObject.AcquireImage({}, onAcquireImageSuccess, onAcquireImageFailure);
    }
  }

Thanks in advance.

解决方案

For the first problem, please check out the other post dwt-java-script-library-progress-dialogue-automatically-displays-with-angular-5

For the 2nd problem. If would appear to be caused by missing of Types definition. Have you included the following line in your TS?

/// <reference types="dwt" />

这篇关于Angular 4 DWT JavaScript库在模型中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆