Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. <div ng-app="app" ng-controller="Ctrl" style="padding:10px">
  2. <h2>Value as numeric</h2>
  3. Comment: Everything is as expected<br />
  4. <a href="#" editable-radiolist="user.status_n" e-ng-options="s.value as s.text for s in ::statuses_n track by s.value">
  5. {{ showStatus_n() }}
  6. </a>
  7.  
  8. <h2>Value as text</h2>
  9. Comment: In edit mode missing selection<br />
  10. <a href="#" editable-radiolist="user.status_t" e-ng-options="s.value as s.text for s in ::statuses_t track by s.value">
  11. {{ showStatus_t() }}
  12. </a>
  13.  
  14. <h2>Value as text with space</h2>
  15. Comment: Throwing error<br />
  16. <a href="#" editable-radiolist="user.status_ts" e-ng-options="s.value as s.text for s in ::statuses_ts track by s.value">
  17. {{ showStatus_ts() }}
  18. </a>
  19. </div>
  20.  
  21. var app = angular.module("app", ["xeditable"]);
  22.  
  23. app.run(function(editableOptions) {
  24. editableOptions.theme = 'bs3';
  25. });
  26.  
  27. app.controller('Ctrl', function($scope, $filter) {
  28. $scope.user = {
  29. status_n: 2,
  30. status_t: 'F',
  31. status_ts: 'G BBB'
  32. };
  33.  
  34. $scope.statuses_n = [
  35. {value: 1, text: 'Male'},
  36. {value: 2, text: 'Female'}
  37. ];
  38. $scope.statuses_t = [
  39. {value: 'M', text: 'Male'},
  40. {value: 'F', text: 'Female'}
  41. ];
  42. $scope.statuses_ts = [
  43. {value: 'G AAA', text: 'Gender 1'},
  44. {value: 'G BBB', text: 'Gender 2'}
  45. ];
  46.  
  47. $scope.showStatus_n = function() {
  48. var selected = $filter('filter')($scope.statuses_n, {value: $scope.user.status_n});
  49. return ($scope.user.status_n && selected.length) ? selected[0].text : 'Not set';
  50. };
  51. $scope.showStatus_t = function() {
  52. var selected = $filter('filter')($scope.statuses_t, {value: $scope.user.status_t});
  53. return ($scope.user.status_t && selected.length) ? selected[0].text : 'Not set';
  54. };
  55. $scope.showStatus_ts = function() {
  56. var selected = $filter('filter')($scope.statuses_ts, {value: $scope.user.status_ts});
  57. return ($scope.user.status_ts && selected.length) ? selected[0].text : 'Not set';
  58. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement