Last active
August 29, 2015 14:16
-
-
Save pdonorio/81e4366111a3a09fe8c3 to your computer and use it in GitHub Desktop.
Select via xeditable in Angular (workaround)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myApp = angular.module('myapp') | |
.controller('SubmissionAdminController', function ($scope) { | |
$scope.types = [ | |
{value: 0, text: 'string'}, | |
{value: 1, text: 'number'}, | |
{value: 2, text: 'range'}, | |
{value: 3, text: 'date'}, | |
{value: 4, text: 'email'}, | |
]; | |
console.log($scope.templates); //from remote | |
//Object {second: 4, last: 2} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- CYCLE TEMPLATES --> | |
<div ng-repeat='(name, type) in templates'> | |
<!-- normal field --> | |
<span href="#" editable-text="name" e-name="label" e-form="rowform" e-required> {{name || 'empty'}} </span> | |
<!-- Two divs visible based on the xeditable form --> | |
<span ng-show="rowform.$visible"> | |
<select ng-model="myselect" ng-init='myselect=types[type] || types[0]' | |
ng-options="mytype.text for mytype in types" ></select> | |
</span> | |
<span ng-hide="rowform.$visible"> {{myselect.text}} </span> | |
</div> | |
<!-- so you need the xeditable form --> | |
<form editable-form name="rowform" ng-show="rowform.$visible" class="form-buttons form-inline"> | |
<!-- usually you put buttons here to do operations with xeditable --> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment