import { Component, ViewChild } from '@angular/core';
import { EJComponents } from './../../../node_modules/ej-angular2/src/ej/core';
@Component({
selector: 'ej-app',
templateUrl: './home.component.html',
})
export class HomeComponent {
data: Array<Object> = [];
fieldsvalues: Object;
@ViewChild('dropdown') dropdown: EJComponents<ej.DropDownList, any>;
constructor() {
this.data = [
{text: "ListItem 1", value: "ListItem 1" },
{text: "ListItem 2", value: "ListItem 2" },
{text: "ListItem 3", value: "ListItem 3" },
{text: "ListItem 4", value: "ListItem 4" },
{text: "ListItem 5", value: "ListItem 5" },
];
this.fieldsvalues = { dataSource: this.data, text: "text", value: "value" };
}
onbind(args){ //triggers when data is bound to dropdownlist
var ddlobj = this.dropdown.widget.element.ejDropDownList("instance"); //control’s instance
ddlobj.setModel({ value: "ListItem 3"}); //setting value to dropdownlist
}
} |