【问题标题】:Nativescript/Angular - Bound tap function in template isn't foundNativescript/Angular - 找不到模板中的绑定点击功能
【发布时间】:2017-07-25 09:21:31
【问题描述】:

尝试创建一个带有两个可点击项目的操作栏,这将导致不同的路线,但我似乎无法将简单的功能绑定到点击事件。

这是我的模板:

<ActionBar title="Map" icon="" class="action-bar">
  <ActionItem (tap)="goToTextMode()">
    <Button text="Text"></Button>
  </ActionItem>
  <ActionItem (tap)="goToSettings()" ios.position="right">
    <Button text="Settings"></Button>
  </ActionItem>
</ActionBar>

内部组件:

goToTextMode(): void {
  this.router.navigate(['text']);
}

goToSettings(): void {
  this.router.navigate(['settings']);
}

但是当我点击“文本”按钮时,我得到了这个:

CONSOLE ERROR [native code]: ERROR TypeError: co.goToTextMode is not a function. (In 'co.goToTextMode()', 'co.goToTextMode' is undefined)

我很困惑为什么会这样,有什么想法吗?

【问题讨论】:

    标签: typescript nativescript nativescript-angular


    【解决方案1】:

    您可以检查导入所有组件的 app-module.ts 文件 - 您的组件是否有正确的 URL。我遇到了同样的错误,因为 module.ts 中的组件 url 不正确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多