angular - 导航失败 : Template parse errors: Can't bind to 'options' since it isn't a known property of 'signature-pad'

标签 angular ionic2 signaturepad ionic3

我正在尝试在我的 ionic 3 项目中实现 angular2 签名板,我遇到了上述问题的错误。 我正在学习本教程 link .它在 ionic2 中工作正常,但是当我在 ionic 3 中尝试时,出现如下错误

Failed to navigate:  Template parse errors:
Can't bind to 'options' since it isn't a known property of 'signature-pad'.
1. If 'signature-pad' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'signature-pad' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
    <ion-col></ion-col>
    <ion-col>
      <signature-pad [ERROR ->][options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signatur"): ng:///ConformsignModule/Conformsign.html@20:21
'signature-pad' is not a known element:
1. If 'signature-pad' is an Angular component, then verify that it is part of this module.
2. If 'signature-pad' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
    <ion-col></ion-col>
    <ion-col>
      [ERROR ->]<signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplet"): ng:///ConformsignModule/Conformsign.html@20:6

you can get the full code in this like i just trying everything in this https://devdactic.com/signature-drawpad-ionic-2/

I think when i use deeplink navigation i am getting this error but when i import my component to app.module.ts everything is working fine

更新

这是我的 .ts 文件

export class Conformsign {

  signature = '';
  isDrawing = false;
  finalData
  @ViewChild(SignaturePad) signaturePad: SignaturePad;
  @Input()
  private signaturePadOptions: Object = { // Check out https://github.com/szimek/signature_pad
    'minWidth': 2,
    'canvasWidth': 400,
    'canvasHeight': 200,
    'backgroundColor': '#f6fbff',
    'penColor': '#666a73'
  };

  constructor(public navCtrl: NavController, public navParams: NavParams, public toastCtrl: ToastController, public holders: Holders, public rest:Rest) {

    this.finalData = this.holders.getData();
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad Conformsign');
  }

  ionViewDidEnter() {
    this.signaturePad.clear()
  }

  drawComplete() {
    this.isDrawing = false;
  }

  drawStart() {
    this.isDrawing = true;
  }

  savePad() {
    this.signature = this.signaturePad.toDataURL();
    this.signaturePad.clear();
    let toast = this.toastCtrl.create({
      message: 'New Signature saved.',
      duration: 3000
    });
    toast.present();

     let conformDelivery = {
      order_id: this.finalData.order_id,
      amountpaid:this.finalData.total,
      customername:this.finalData.firstname,
      signature:this.signature,
      user_id:this.finalData.user_id,
      customer_id:this.finalData.customer_id
    }

  }

  clearPad() {
    this.signaturePad.clear();
  }

}

这是我的.html

<ion-content>
  <div class="title">Please draw your Signature</div>
  <ion-row [ngClass]="{'drawing-active': isDrawing}">
    <ion-col></ion-col>
    <ion-col>
      <signature-pad [options]="signaturePadOptions" (onBeginEvent)="drawStart()" (onEndEvent)="drawComplete()"></signature-pad>
    </ion-col>
    <ion-col></ion-col>

  </ion-row>
  <button ion-button full color="danger" (click)="clearPad()">Clear</button>
  <button ion-button full color="secondary" (click)="savePad()">Save</button>

  <ion-row>
    <ion-col></ion-col>
    <ion-col width-80>
      <img [src]="signature"/>
    </ion-col>
    <ion-col></ion-col>
  </ion-row>

</ion-content>

最佳答案

我也遇到了这个问题。我通过 devdactic https://devdactic.com/signature-drawpad-ionic-2/ 对原始帖子的评论解决了这个问题。

一个叫 Ka mok 的人向我指出了一些东西

如果您在组件中使用签名板。在我的例子中,我在 farmer 组件中使用它,该组件通常有一个 farmer.module.ts 文件。所以只需导入签名板模块,一切都会正常工作

例如

farmer.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { FarmerPage } from './farmer';
import { SignaturePadModule } from 'angular2-signaturepad';

@NgModule({
  declarations: [
    FarmerPage,
  ],
  imports: [
    IonicPageModule.forChild(FarmerPage),
    SignaturePadModule // this saved my life
  ],
})
export class FarmerPageModule {}

农民.ts

import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';
import { NativeStorage } from '@ionic-native/native-storage';
import { ToastController } from 'ionic-angular';

最后确保你也导入了 app.module.ts 中的模块

我希望这对某人有所帮助。谢谢

关于angular - 导航失败 : Template parse errors: Can't bind to 'options' since it isn't a known property of 'signature-pad' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43586601/

相关文章:

Angular 4 - 属性值未在 View 中更新

Javascript 将 URL 转换为 BASE64 图像

javascript - 监听 AngularJs 中签名板的变化

react-native - 如何在 React Native 中进行签名捕获?

javascript - Primeng系列压光机输出问题

android - 如何有条件地在 ionic 4 中设置根页面?

javascript - 如何使用JAX-RS在REST中将Javascript日期传递给Java LocalDate和LocalDateTime

javascript - Angular 2 中的事件选项卡问题 - 选项卡

html - ionic2 谷歌地图街景在任何 iPhone 设备上运行时不加载图像

jquery - 在 Rails 4 中捕获数字签名的最佳方法是什么?