I am using x-editable in angularjs.
When i submit the select.
I do not get the new value with $data as given in documentation
here is the fiddle http://jsfiddle.net/NfPcH/7014/
script :
var app = angular.module("app", ["xeditable", "ngMockE2E"]);
app.run(function(editableOptions) {
editableOptions.theme = 'bs3';
});
app.controller('Ctrl', function($scope, $q, $http) {
$scope.items = ['a','b','c'];
$scope.user = {
id: 1,
name: 'a'
};
$scope.updateUser = function(data) {
alert(data);
$scope.console = data;
return $http.post('/updateUser', {id: $scope.user.id, name: data});
};
});
// mock `/updateUser` request
app.run(function($httpBackend) {
$httpBackend.whenPOST(/\/updateUser/).respond(function(method, url, data) {
data = angular.fromJson(data);
if(data.name === 'error') {
return [500, 'Error message'];
} else {
return [200, {status: 'ok'}];
}
});
});
Can anyone help me out, how do i get the updated value?
Your problem is your trying to read s.text in your html, but you don't have a text key in your array!
Change....
ng-options="s.text as s for s in items"
to
ng-options="s for s in items"
and it seems to work.