JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="http://vitalets.github.io/angular-xeditable/dist/js/xeditable.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://vitalets.github.io/angular-xeditable/dist/css/xeditable.css">
<script src="http://code.angularjs.org/1.0.8/angular-mocks.js"></script>
<h4>Angular-xeditable Select remote (Bootstrap 3)</h4>
<div ng-app="app" ng-controller="Ctrl">
<a href="#" editable-select="user.group" onshow="loadGroups()" e-ng-options="g.id as g.text for g in groups">
{{ user.groupName || 'not set' }}
</a>
</div>
CSS
div[ng-app] { margin: 50px; }
JavaScript
var app = angular.module("app", ["xeditable", "ngMockE2E"]);
app.run(function(editableOptions) {
editableOptions.theme = 'bs3';
});
app.controller('Ctrl', function($scope, $filter, $http) {
$scope.user = {
group: 4,
groupName: 'admin' // original value
};
$scope.groups = [];
$scope.loadGroups = function() {
return $scope.groups.length ? null : $http.get('/groups').success(function(data) {
$scope.groups = data;
});
};
$scope.$watch('user.group', function(newVal, oldVal) {
if (newVal !== oldVal) {
var selected = $filter('filter')($scope.groups, {id: $scope.user.group});
$scope.user.groupName = selected.length ? selected[0].text : null;
}
});
});
// mock `/groups` request
app.run(function($httpBackend) {
$httpBackend.whenGET('/groups').respond([
{id: 1, text: 'user'},
{id: 2, text: 'customer'},
{id: 3, text: 'vip'},
{id: 4, text: 'admin'}
]);
});