2016-11-14 30 views
0

我覺得我正在關注Query/QueryList的這個文檔,但是我仍然收到錯誤「(SystemJS)裝飾器不是函數。」Decorator不是一個函數 - Angular 2

我正確定義Query和QueryList嗎?

import { Directive, OnInit, OnDestroy, Input, Output, HostBinding, 
    EventEmitter, ElementRef, ContentChildren, ViewChildren, 
    Query, QueryList } from '@angular/core'; 
import { DropdownMenuInterface } from './dropdown.interface'; 
import { DropdownToggleInterface } from './dropdown.interface'; 
import { dropdownService, NONINPUT} from './dropdown.service'; 

@Directive({selector: '[dropdown]'}) 
export class Dropdown implements OnInit, OnDestroy { 

    ...... 

    // index of selected element 
    public selectedOption:number; 
    // drop menu html 
    public menuEl:ElementRef; 
    // drop down toggle element 
    public toggleEl:ElementRef; 

    dropdownMenuList: QueryList<ElementRef>; 

    constructor(public el:ElementRef, 
     @Query('dropdownMenu') dropdownMenuList: QueryList<ElementRef>) { 
    } 

    public set isOpen(value) { 
    this._isOpen = !!value; 

    ..... 

}

+0

我相信這個問題是關係到SystemJS配置,而不是你的代碼。 – rzelek

回答

0

兩個QueryQueryList不是裝飾,但類型(或類別反正)。

我覺得@ViewChildren設立的私人財產,根據Query傳遞給它(我認爲Query爲對象的,你需要發送到查詢的裝飾之一(@ViewChildren@ViewChild@ContentChild@ContentChildren類型進行更新)。

而且QueryList是屬性的類型,如果你已經使用了Children(不Child)的查詢裝飾的變種之一。

相關問題