Arter Arter - 1 year ago 151
AngularJS Question

angularjs xeditable - ng-options

i have problem with getting id from selected distributor. Here is my html code for select distributor

<span editable-select="currentKlupa.distributor" e-form="tableform" e-ng-options="user as user for user in getAllUserFromRolesPushano">{{::currentKlupa.distributor.username}}

I also have another select box, and all working correct, but this one not, because i need get id from this select.

here is controller

$scope.getUserFromRoles = function (rolaProslijedena) {
$scope.getAllUserFromRolesPushano = [];
$scope.getAllUserFromRoles = dohvacanjeUseraPoRolama.get({rola: rolaProslijedena});
$scope.getAllUserFromRoles.$promise.then(function (data) {
angular.forEach(data.users, function (key, value){


I need to get id from this selected distributor, how to set ng-options for this? Thnx

Answer Source

Without more informations, I give you an example with a tricks (i haven't found a better solution yet):

I have a Show done by an artist.

$scope.shows = {artist_id : 4};

and a list of artists.

$scope.artists = [{id : 1, name : 'artist1'},{id : 2, name : 'artist2'},...];

my html will be:

<span editable-select="shows.artist_id" e-name="name" e-form="rowform"  e-ng-options="g._id as for g in artists">

The trick is the use of DisplayName.

$scope.DisplayName= function(item) {
  var selected = $scope.artists.filter(function( obj ) {return (obj._id == item.artist_id)})[0]

This is really not the best solution but that works.

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