首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >装饰器不是函数-角度2

装饰器不是函数-角度2
EN

Stack Overflow用户
提问于 2016-11-15 07:50:35
回答 1查看 396关注 0票数 0

我觉得我是按照文档中的说明来查询/查询列表的,但是我仍然收到错误消息"(SystemJS)装饰器不是一个函数“。

我是否正确地定义了查询和QueryList?

代码语言:javascript
复制
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;

   .....

}

EN

回答 1

Stack Overflow用户

发布于 2016-11-15 21:34:34

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

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

如果您使用过查询装饰器的Children (不是Child)变体之一,那么QueryList就是该属性的类型。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40599797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档