Introduction:
Here I will explain how to use AngularJS to get dropdownlist selected value and text using ng-change event with example or use dropdown list ng-change event to get selected value and text using AngularJS with examples. By using ng-model property in AngularJS we can get dropdownlist selected value and text in ng-change event.
Description:
In previous articles I explained Angularjs ui grid cell template click event, bind dropdownlist in angularjs, Angularjs convert lower case to upper case while typing text, Angularjs refresh div for every 1 second using interval mode and many articles relating to AngularJS, jQuery, JavaScript and asp.net. Now I will explain how to get dropdownlist selected value and text in ng-change event using AngularJS.
In previous articles I explained Angularjs ui grid cell template click event, bind dropdownlist in angularjs, Angularjs convert lower case to upper case while typing text, Angularjs refresh div for every 1 second using interval mode and many articles relating to AngularJS, jQuery, JavaScript and asp.net. Now I will explain how to get dropdownlist selected value and text in ng-change event using AngularJS.
To get dropdownlist selected value and text in
ng-change event we can use ng-model
option in
AngularJS
like as shown below
$scope.getselectval = function () {
$scope.selectedvalues= 'Name: ' +
$scope.selitem.name + ' Id: ' +
$scope.selitem.id;
}
Select Name: <select ng-options="s.name for s in sample" ng-model="selitem"
ng-change="getselectval()">
<option value="">--Select--</option>
</select>
<p> {{selectedvalues}}</p>
|
If
you want to check it in complete example you need to write the code like as
shown below
|
Live
Demo
To
check live demo try to change below sample dropdownlist value
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
4 comments :
nice article
muy bueno
i want to pupulte data from db...i have written function as $http({
method: 'GET',
url: '/Home/getAllCountries'
}).then(function (data) {
alert(data);
$scope.sample = data.data;
}, function () {
alert('Error');
});
but not working...pls try to resolve
i want proper database using web api arltical.
Note: Only a member of this blog may post a comment.