我正在使用 angular2,我有一个下拉列表,并且我有一个要在(change)
事件中调用的函数。但是这个事件没有触发。以下是我的代码
import {Component, EventEmitter, OnInit} from 'angular2/core';
import {perPageCount} from './interface';
import {CORE_DIRECTIVES} from 'angular2/common';
@Component({
selector: 'table-content',
template:
`<div class="dropdown-wrap ">
<select name="" tabindex="1" (change)="onSelect($event.target.value)">
<option *ngFor="#perPageCount of perPageCounts; #i=index" value="{{perPageCount.value}}" [attr.selected]="i == 0 ? true : null" >
{{perPageCount.text}}
</option>
</select>
</div>`,
providers: [CORE_DIRECTIVES]
})
export class tablecontent {
public perPageCounts: perPageCount[] = [
{ text: 10, value: 1 },
{ text: 25, value: 2 },
{ text: 50, value: 3 },
{ text: 100, value: 4 }
];
public ipp: number = this.perPageCounts[0].text;
onSelect(value) {
this.ipp = null;
for (var i = 0; i < this.perPageCounts.length; i++) {
if (this.perPageCounts[i].value == value) {
this.ipp = this.perPageCounts[i].text;
console.log(this.ipp)
}
}
}
下拉列表正在加载,但onSelect(value)
功能未触发!请有人帮忙!!