我是新来的打字稿,我正在尝试为angular 2指令创建一个函数。 任何人都可以用n00bs的语言解释,当我用Gulp编译时,错误是想告诉我什么?angular 2 typescript一个实现不能在环境中声明
的实现不能在周围环境
的信息适用于offset()
和toggler()
声明。
import { Directive, ElementRef, Input } from '@angular/core';
@Directive({
selector: 'offCanvas',
inputs: ['target', 'toggle', 'placement', 'autohide', 'recalc', 'disableScrolling', 'modal', 'canvas', 'exclude'],
host: {
'(click)': 'Click()'
}
})
export class OffCanvas {
@Input('target') target: string;
@Input('canvas') canvas: string;
@Input('state') state: string;
@Input('exclude') exclude: string;
@Input('placement') placement: string;
@Input('toggle') toggle: boolean;
@Input('autohide') autohide: boolean;
@Input('recalc') recalc: boolean;
@Input('disableScrolling') disableScrolling: boolean;
@Input('modal') modal: boolean;
public offset() {
switch (this.placement) {
case 'left':
case 'right': return (<HTMLElement>document.querySelector(this.target)).offsetWidth
case 'top':
case 'bottom': return (<HTMLElement>document.querySelector(this.target)).offsetHeight
}
}
public toggler() {
if (this.state === 'slide-in' || this.state === 'slide-out') return
this[this.state === 'slid' ? 'hide' : 'show']()
}
Click() {
this.toggler()
}
}
我觉得很愚蠢...... – poashoas
别担心。所以我的https://en.wikipedia.org/wiki/Impostor_syndrome – basarat
大声笑,这个综合症让我做到了 – poashoas