未处理的承诺拒绝:;区域:角;任务:

时间:2016-04-26 17:54:53

标签: javascript meteor typescript angular

meteor和设置(click)属性时出现以下错误。

error

我的代码是

import { Component, NgZone, AfterContentInit } from 'angular2/core';
import { NgIf, NgFor } from 'angular2/common';
import { Accounts } from 'meteor/accounts-base';
import { RouterLink, RouteConfig, Router, ROUTER_DIRECTIVES } from 'angular2/router';
import { CapitalizePipe } from '../../../../lib/pipes/capitalize.ts';
import { Groups } from '../../../../collections/groups.ts';
import { MeteorComponent } from 'angular2-meteor/meteor_component';
import { Meteor } from 'meteor/meteor';

@Component({
  selector: 'manage-players',
  templateUrl: '/client/components/loggedIn/players/manage-players.html',
  directives: [ RouterLink, NgIf, NgFor ],
  pipes: [CapitalizePipe]
})

export class ManagePlayers extends MeteorComponent {
  importPlayers: Object;
  groups: Mongo.Cursor;
  pendingImport_placementGroups: Array;
  pendingImport_players: Array;

  constructor( zone:NgZone ){
    super();
    var that = this;
    this.subscribe('groups', () => {
      this.groups = Groups.find();
    },true);
  }

  createImportGroups() {
    console.log('Do something!');
  }

触发html是:

<a href="#!" class="create-import-groups btn-flat" (click)="createImportGroups()" >Create Groups</a>

每当我点击上面的链接时,我都会收到上述错误。 很抱歉,如果我错误地格式化了我的问题或遗漏了任何信息,我在Stack Overflow上提问时仍然相对较新。

1 个答案:

答案 0 :(得分:0)

看来我找到了自己问题的答案,虽然我对Angular2甚至javascript都没有足够的经验或知识,无法理解为什么。

我的问题的解决方案是我使用了一个带有click事件的锚标签,我相信这是因为angular有自己的方式处理锚标签,而(click)属性试图干扰该功能。

原件:

from ctypes import *

width, height = 512, 512

class SimpleCapParms(Structure):
    _fields_ = [
        ("mTargetBuf", POINTER(c_int)),
        ("mWidth", c_int),
        ("mHeight", c_int),
    ]

array_type = (width * height * c_int)
array = array_type()
options = SimpleCapParms()
options.mWidth = width
options.mHeight = height
options.mTargetBuf = array

lib = cdll.LoadLibrary('escapi.dll')
lib.initCapture.argtypes = [c_int, POINTER(SimpleCapParms)]
lib.initCapture.restype = c_int
lib.initCOM()

lib.initCapture(0, byref(options))
lib.doCapture(0)

while lib.isCaptureDone(0) == 0:
    pass

print(array[100])

lib.deinitCapture(0)

替换为:

  <a href="#!" class="create-import-groups btn-flat" (click)="createImportGroups()" >Create Groups</a>

如果有的话,我还是想更多地了解这个主题。