Skip to content

Instantly share code, notes, and snippets.

@roktas
Created November 5, 2013 23:51
Show Gist options
  • Save roktas/7328468 to your computer and use it in GitHub Desktop.
Save roktas/7328468 to your computer and use it in GitHub Desktop.
A Pen by Recai Oktaş.
<h4>Angular-xeditable demo</h4>
<div ng-app="app" ng-controller="Ctrl" style="margin: 50px">
<a href="#" editable-text="user.name">{{ user.name || 'empty' }}</a>
<br><br>
<a href="#" editable-select="user.status" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
<br><br>
debug: {{ user | json }}
</div>
app = angular.module("app", ["xeditable"])
app.run (editableOptions) ->
editableOptions.theme = "bs3"
app.controller "Ctrl", ($scope, $filter) ->
$scope.user =
name: "cezmi seha sahir"
status: 2
$scope.statuses = [
value: 1
text: "status1"
,
value: 2
text: "status2"
,
value: 3
text: "status3"
,
value: 4
text: "status4"
]
$scope.showStatus = ->
selected = $filter("filter")($scope.statuses,
value: $scope.user.status
)
(if ($scope.user.status and selected.length) then selected[0].text else "Not set")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment