装饰者不是一个功能 - Angular 2

时间:2016-11-14 23:50:35

标签: angular

我觉得我正在关注Query / QueryList的文档,但我仍然得到错误“(SystemJS)装饰器不是一个函数。”

我是否正确定义了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;

   .....

}

1 个答案:

答案 0 :(得分:0)

QueryQueryList都不是装饰器,而是类型(或类)。

我认为@ViewChildren设置了一个私有属性,根据传递给它的Query进行更新(我认为Query是您需要发送给它的对象类型查询装饰器(@ViewChildren@ViewChild@ContentChild@ContentChildren)。

如果您使用查询装饰器的QueryList(非Children)变体之一,则Child是属性的类型。

相关问题