Advertisements

Archive

Posts Tagged ‘get selected text’

AngularJS: Get selected Text and Value of HTML Select DropDownList using ng-change


The below HTML Markup consists of an HTML DIV to which ng-app and ng-controller AngularJS directives have been assigned.

The HTML DIV consists of an HTML Select DropDownList which will be populated from JSON array using ng-options directive.

The HTML Select DropDownList has been assigned ng-change directive. When an option is selected in HTML Select DropDownList then the GetValue function of the Controller gets called.
Inside the function, first the selected Value is fetched from the ng-model attribute and the selected Text is fetched from the JSON array using jQuery grep function.
Finally the selected Text and Value is displayed using JavaScript alert message box.

2016-06-21_1554

Advertisements