angularjs xeditable - of-options

angularjs xeditable - ng-options

我在从 selected 分销商处获取 ID 时遇到问题。这是我的 html 代码 select 分销商

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

我还有另一个 select 框,一切正常,但这个不行,因为我需要从这个 select 获取 ID。

这里是控制器

$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){
                $scope.getAllUserFromRolesPushano.push(key.username);
            });

        });
    };

我需要从这个 selected 经销商处获取 ID,如何为此设置 ng-options?谢谢

没有更多信息,我给你一个有技巧的例子(我还没有找到更好的解决方案):

我有一个 Show 由艺术家完成。

$scope.shows = {artist_id : 4};

艺术家列表

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

我的 html 将是:

<span editable-select="shows.artist_id" e-name="name" e-form="rowform"  e-ng-options="g._id as g.name for g in artists">
    {{DisplayName(shows)}}
</span>

技巧 是使用 DisplayName。

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

这确实不是最好的解决方案,但确实有效。