Lakshmi Narasimhan Lakshmi Narasimhan - 1 year ago 77
AngularJS Question

Is there a way to get the value of {{org}} from this?

<input type="text" ng-model="selectedOrg" ng-show="!isSuperAdmin" readonly />
<select id="nameOrg" ng-model="selectedOrg" ng-change="changeOrg()" ng-disabled="!isSuperAdmin" ng-show="isSuperAdmin">
<option ng-repeat="org in orglist">{{org}}</option>
var value = $(nameOrg).val()

Answer Source

Without the quotes, nameOrg is an invalid JavaScript variable.


Here's the right way to select an element by it's ID:



Also, I see your html document does not contain any reference of jQuery. Make sure you are importing the library.

<script src=""></script>

I strongly suggest wrapping the code in a jQuery ready function as well, otherwise $ will not be available at runtime.

After you have done all the above, refer to the linked duplicate question on how to get the selected text. What .val() does is to get the selected option's value (<option value="text"></option>), not the text between the option tag (<option>text</option>).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download