我想将自定义指令中的“ngFor”索引绑定为属性我做错了什么?
这段代码:
@Directive({selector: '[closeWeb]'})
class CountClicks {
numberOfClicks = 0;
@HostListener('touchstart', ['$event.target'])
touchstart(btn) {
console.log(btn)
}
}
@Component({
selector: 'wrap',
template: `
<div class="wrap">
<div class="item" *ngFor="#webviews of webviewsCount; #i = index">
<!-- I want to bind index in custom directive as attribute -->
<div [closeWeb]="i">{{i}}</div>
</div>
</div>
`,
directives: [CountClicks]
})
export class Wrap {}
我得到这个错误:
EXCEPTION: Template parse errors:
Can't bind to 'closeWeb' since it isn't a known native property ("</div><div [ERROR ->][closeWeb]="i">{{i}}</div></div></div>"): Wrap@9:21