我觉得我是按照文档中的说明来查询/查询列表的,但是我仍然收到错误消息"(SystemJS)装饰器不是一个函数“。
我是否正确地定义了查询和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;
.....}
发布于 2016-11-15 21:34:34
Query和QueryList都不是装饰器,而是类型(或类)。
我认为@ViewChildren设置了一个私有属性,根据传递给它的Query进行更新(我认为Query是需要发送给查询装饰器之一的对象类型(@ViewChildren、@ViewChild、@ContentChild和@ContentChildren)。
如果您使用过查询装饰器的Children (不是Child)变体之一,那么QueryList就是该属性的类型。
https://stackoverflow.com/questions/40599797
复制相似问题