forked from vitalets/angular-xeditable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2610 lines (2449 loc) · 116 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Angular-xeditable :: Edit in place for AngularJS</title>
<!--theme: Bootstrap 3, Bootstrap 2, default-->
<link href="libs/bootstrap/3.0.0/css/bootstrap.css" rel="stylesheet" media="screen">
<!--xeditable css-->
<link href="dist/css/xeditable.css" rel="stylesheet" media="screen">
<!--docs css-->
<link href="docs/css/docs.css" rel="stylesheet" media="screen">
<!--angular-->
<script src="libs/angular/1.2.7/angular.js"></script>
<script src="libs/angular/1.2.7/angular-mocks.js"></script>
<!--jquery (needed for bootstrap)-->
<script src="libs/jquery/jquery-1.10.2.min.js"></script>
<!--bootstrap-->
<script src="libs/bootstrap/3.0.0/js/bootstrap.js"></script>
<!--angular-ui-bootstrap-->
<script src="libs/angular-ui/bootstrap/ui-bootstrap-tpls-0.6.0.min.js"></script>
<!--moment-->
<script src="libs/moment.min.2.5.0.js"></script>
<!--google-code-prettify-->
<script src="libs/google-code-prettify/run_prettify.js"></script>
<!--checklist-model-->
<script src="libs/checklist-model.js"></script>
<!--app-->
<script src="docs/js/app.js"></script>
<!--xeditable-->
<script src="dist/js/xeditable.min.js"></script>
</head>
<body data-spy="scroll" data-target=".sidebar">
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" data-toggle="collapse" data-target=".navbar-ex1-collapse" class="navbar-toggle"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a href="#" class="navbar-brand">Angular-xeditable </a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="https://github.com/vitalets/angular-xeditable">Github</a></li>
</ul>
<form class="navbar-form navbar-right"><a href="zip/angular-xeditable-0.1.10.zip" style="font-weight:bold" class="btn btn-primary"><span style="margin-right:10px" class="glyphicon glyphicon-save"></span>Download 0.1.10 ~ kb</a></form>
<div style="padding-top: 13px">
<!-- google+ -->
<div id="socials" style="text-align: center">
<div style="display: inline-block" class="g-plusone" data-size="medium" data-href="http://vitalets.github.io/angular-xeditable"></div>
<script type="text/javascript">
(function() {
if (!isProd()) return;
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<!-- facebook -->
<div id="fb-root" style="display: inline-block"></div>
<script>
(function(d, s, id) {
if (!isProd()) return;
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=558710054143871";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div style="vertical-align:top;zoom:1;*display:inline;display: inline-block; text-align:left; margin: 1px 30px 0 0" class="fb-like" data-href="http://vitalets.github.io/angular-xeditable" data-send="false" data-layout="button_count" data-width1="450" data-show-faces="false"></div>
<!-- twitter -->
<a style="vertical-align:top" href="https://twitter.com/share" class="twitter-share-button" data-url="http://vitalets.github.io/angular-xeditable" data-via="xeditable">Tweet</a>
<script>!function(d,s,id){
if (!isProd()) return;
var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
</script>
</div>
</div>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-sm-3 col-xs-12">
<div class="well sidebar">
<ul class="nav">
<li><a href="#overview">Overview</a>
<ul class="nav">
</ul>
</li>
<li><a href="#getstarted">Get started</a>
<ul class="nav">
</ul>
</li>
<li><a href="#text-simple">Controls</a>
<ul class="nav">
<li><a href="#text-simple">Text</a></li>
<li><a href="#select-local">Select local</a></li>
<li><a href="#select-remote">Select remote</a></li>
<li><a href="#html5-inputs">HTML5 inputs</a></li>
<li><a href="#textarea">Textarea</a></li>
<li><a href="#checkbox">Checkbox</a></li>
<li><a href="#checklist">Checklist</a></li>
<li><a href="#radiolist">Radiolist</a></li>
<li><a href="#bsdate">Date</a></li>
<li><a href="#bstime">Time</a></li>
<li><a href="#combodate">DateTime</a></li>
<li><a href="#typeahead">Typeahead</a></li>
</ul>
</li>
<li><a href="#text-customize">Techniques</a>
<ul class="nav">
<li><a href="#text-customize">Customize input</a></li>
<li><a href="#text-btn">Trigger manually</a></li>
<li><a href="#select-nobuttons">Hide buttons</a></li>
<li><a href="#select-multiple">Select multiple</a></li>
<li><a href="#validate-local">Validate local</a></li>
<li><a href="#validate-remote">Validate remote</a></li>
</ul>
</li>
<li><a href="#onbeforesave">Submit</a>
<ul class="nav">
<li><a href="#onbeforesave">Onbeforesave</a></li>
<li><a href="#onaftersave">Onaftersave</a></li>
</ul>
</li>
<li><a href="#editable-form">Forms</a>
<ul class="nav">
<li><a href="#editable-form">Editable form</a></li>
</ul>
</li>
<li><a href="#editable-row">Tables</a>
<ul class="nav">
<li><a href="#editable-row">Editable row</a></li>
<li><a href="#editable-column">Editable column</a></li>
<li><a href="#editable-table">Editable table</a></li>
</ul>
</li>
<li><a href="#bootstrap3">Themes</a>
<ul class="nav">
<li><a href="#bootstrap3">Bootstrap 3</a></li>
<li><a href="#bootstrap2">Bootstrap 2</a></li>
<li><a href="#default">Default</a></li>
</ul>
</li>
<li><a href="#ref-element">Reference</a>
<ul class="nav">
<li><a href="#ref-element">Editable element</a></li>
<li><a href="#ref-form">Editable form</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-sm-9 col-xs-12">
<!-- render-->
<section id="overview"></section>
<h1>Overview</h1>
<!-- jade cannot include dynamically--><p><strong>Angular-xeditable</strong> is a bundle of <a href="http://angularjs.org">AngularJS</a> directives that allows you to create
<em>editable elements</em>.<br>Such technique is also known as <em>click-to-edit</em> or <em>edit-in-place</em>.<br>It is based on ideas of <a href="http://vitalets.github.io/x-editable">x-editable</a> but was written from scratch
to use power of angular and support complex forms / editable grids.</p>
<h4>Dependencies</h4><p>Basically it does not depend on any libraries except <a href="http://angularjs.org">AngularJS</a> itself.<br>For themes you may need to include <a href="http://getbootstrap.com">Twitter Bootstrap</a> CSS.<br>For some extra controls (e.g. datepicker) you may need to include <a href="http://angular-ui.github.io/bootstrap/">angular-ui bootstrap</a>.</p>
<h4>Controls & Features</h4>
<table style="width: 50%; min-width: 200px">
<tr>
<td style="width: 50%; vertical-align: top"><ul>
<li><a href="#text-simple">text</a> </li>
<li><a href="#textarea">textarea</a></li>
<li><a href="#select-local">select</a></li>
<li><a href="#checklist">checkbox</a></li>
<li><a href="#radiolist">radio</a></li>
<li><a href="#bsdate">date</a></li>
<li><a href="#bstime">time</a></li>
<li><a href="#combodate">datetime</a></li>
<li><a href="#html5-inputs">html5 inputs</a> </li>
<li><a href="#typeahead">typeahead</a></li>
</ul>
</td>
<td style="width: 50%; vertical-align: top"><ul>
<li><a href="#editable-form">complex form</a></li>
<li><a href="#editable-row">editable row</a></li>
<li><a href="#editable-column">editable column</a></li>
<li><a href="#editable-table">editable table</a></li>
<li><a href="#themes">themes</a></li>
</ul>
</td>
</tr>
</table>
<section id="getstarted"></section>
<h1>Get started</h1>
<!-- jade cannot include dynamically-->
<ol>
<li> <p>Include <a href="http://angularjs.org">Angular.js</a> in your project</p>
<pre class="prettyprint"><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script></pre><p>Optionally include <a href="http://getbootstrap.com">Bootstrap</a> CSS for theming</p>
<pre class="prettyprint"><link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"></pre>
</li>
<li> <span>Install angular-xeditable via </span><a href="http://bower.io" target="_blank">bower</a><span> or </span><a href="zip/angular-xeditable-0.1.10.zip">download latest zip </a>
<pre class="prettyprint">bower install angular-xeditable </pre>
</li>
<li>Include angular-xeditable into your project
<pre class="prettyprint"><link href="bower_components/angular-xeditable/dist/css/xeditable.css" rel="stylesheet">
<script src="bower_components/angular-xeditable/dist/js/xeditable.js"></script></pre>
</li>
<li>Define angular app and add "xeditable" to dependencies
<pre class="prettyprint"><html ng-app="app"></pre>
<pre class="prettyprint">var app = angular.module("app", ["xeditable"]);</pre>
</li>
<li>Set theme in app.run:
<pre class="prettyprint">app.run(function(editableOptions) {
editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
});
</pre>
</li>
<li>Markup element that should be editable
<pre ng-non-bindable class="prettyprint"><div ng-controller="Ctrl">
<a href="#" editable-text="user.name">{{ user.name || "empty" }}</a>
</div></pre>
</li>
<li>Define controller
<pre class="prettyprint">app.controller('Ctrl', function($scope) {
$scope.user = {
name: 'awesome user'
};
});</pre>
</li>
<li>Enjoy!
<div style="padding-top: 5px"> <a href="starter" target="_blank" class="btn btn-success">View starter template</a><a href="zip/angular-xeditable-starter.zip" style="margin-left: 10px" class="btn btn-primary">Download starter zip</a></div>
</li>
</ol>
<section id="text-simple">
<h1>Text</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/25/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="TextSimpleCtrl">
<a href="#" editable-text="user.name">{{ user.name || 'empty' }}</a>
</div></div>
<pre>{{ debug["text-simple"] | json }}</pre>
<p><p>To make element editable via textbox just add <code>editable-text="model.field"</code> attribute.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('TextSimpleCtrl', function($scope) {
$scope.user = {
name: 'awesome user'
};
$scope.$watch("user", function(v) { $scope.$parent.debug["text-simple"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="TextSimpleCtrl">
<a href="#" editable-text="user.name">{{ user.name || 'empty' }}</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('TextSimpleCtrl', function($scope) {
$scope.user = {
name: 'awesome user'
};
});</pre>
</section>
<section id="select-local">
<h1>Select local</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/28/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="SelectLocalCtrl">
<a href="#" editable-select="user.status" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></div>
<pre>{{ debug["select-local"] | json }}</pre>
<p><p>To create editable select (dropdown) just set <code>editable-select</code> attribute pointing to model.
To pass dropdown options you should define <code>e-ng-options</code> attribute
that works like normal angular <code>ng-options</code> but is transfered to underlying <code><select></code> from original element.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('SelectLocalCtrl', function($scope, $filter) {
$scope.user = {
status: 2
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'},
{value: 4, text: 'status4'}
];
$scope.showStatus = function() {
var selected = $filter('filter')($scope.statuses, {value: $scope.user.status});
return ($scope.user.status && selected.length) ? selected[0].text : 'Not set';
};
$scope.$watch("user", function(v) { $scope.$parent.debug["select-local"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="SelectLocalCtrl">
<a href="#" editable-select="user.status" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('SelectLocalCtrl', function($scope, $filter) {
$scope.user = {
status: 2
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'},
{value: 4, text: 'status4'}
];
$scope.showStatus = function() {
var selected = $filter('filter')($scope.statuses, {value: $scope.user.status});
return ($scope.user.status && selected.length) ? selected[0].text : 'Not set';
};
});</pre>
</section>
<section id="select-remote">
<h1>Select remote</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/29/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="SelectRemoteCtrl">
<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></div>
<pre>{{ debug["select-remote"] | json }}</pre>
<p><p>To load select options from remote url you should define <code>onshow</code> attribute pointing to scope function.
The result of function should be a $http promise, it allows to disable element while loading.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('SelectRemoteCtrl', 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;
}
});
$scope.$watch("user", function(v) { $scope.$parent.debug["select-remote"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="SelectRemoteCtrl">
<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></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('SelectRemoteCtrl', 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;
}
});
});</pre>
</section>
<section id="html5-inputs">
<h1>HTML5 inputs</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/82/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="Html5InputsCtrl">
<div>Email: <a href="#" editable-email="user.email">{{ user.email || 'empty' }}</a></div>
<div>Tel: <a href="#" editable-tel="user.tel" e-pattern="\d{3}\-\d{2}\-\d{2}" e-title="xxx-xx-xx">{{ user.tel || 'empty' }}</a></div>
<div>Number: <a href="#" editable-number="user.number" e-min="18">{{ user.number || 'empty' }}</a></div>
<div>Range: <a href="#" editable-range="user.range" e-step="5">{{ user.range || 'empty' }}</a></div>
<div>Url: <a href="#" editable-url="user.url">{{ user.url || 'empty' }}</a></div>
<div>Search: <a href="#" editable-search="user.search">{{ user.search || 'empty' }}</a></div>
<div>Color: <a href="#" editable-color="user.color">{{ user.color || 'empty' }}</a></div>
<div>Date: <a href="#" editable-date="user.date">{{ user.date || 'empty' }}</a></div>
<div>Time: <a href="#" editable-time="user.time">{{ user.time || 'empty' }}</a></div>
<div>Datetime: <a href="#" editable-datetime="user.datetime">{{ user.datetime || 'empty' }}</a></div>
<div>Month: <a href="#" editable-month="user.month">{{ user.month || 'empty' }}</a></div>
<div>Week: <a href="#" editable-week="user.week">{{ user.week || 'empty' }}</a></div>
</div></div>
<pre>{{ debug["html5-inputs"] | json }}</pre>
<p><p>Following HTML5 types are supported via <code>editable-xxx</code> directive:</p>
<ul>
<li>email</li>
<li>tel</li>
<li>number</li>
<li>search</li>
<li>range</li>
<li>url</li>
<li>color</li>
<li>date</li>
<li>datetime</li>
<li>time</li>
<li>month</li>
<li>week</li>
</ul>
<p>Please <a href="http://caniuse.com/">check browser support</a> before using particular type in your project.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('Html5InputsCtrl', function($scope) {
$scope.user = {
email: '[email protected]',
tel: '123-45-67',
number: 29,
range: 10,
url: 'http://example.com',
search: 'blabla',
color: '#6a4415',
date: null,
time: '12:30',
datetime: null,
month: null,
week: null
};
$scope.$watch("user", function(v) { $scope.$parent.debug["html5-inputs"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="Html5InputsCtrl">
<div>Email: <a href="#" editable-email="user.email">{{ user.email || 'empty' }}</a></div>
<div>Tel: <a href="#" editable-tel="user.tel" e-pattern="\d{3}\-\d{2}\-\d{2}" e-title="xxx-xx-xx">{{ user.tel || 'empty' }}</a></div>
<div>Number: <a href="#" editable-number="user.number" e-min="18">{{ user.number || 'empty' }}</a></div>
<div>Range: <a href="#" editable-range="user.range" e-step="5">{{ user.range || 'empty' }}</a></div>
<div>Url: <a href="#" editable-url="user.url">{{ user.url || 'empty' }}</a></div>
<div>Search: <a href="#" editable-search="user.search">{{ user.search || 'empty' }}</a></div>
<div>Color: <a href="#" editable-color="user.color">{{ user.color || 'empty' }}</a></div>
<div>Date: <a href="#" editable-date="user.date">{{ user.date || 'empty' }}</a></div>
<div>Time: <a href="#" editable-time="user.time">{{ user.time || 'empty' }}</a></div>
<div>Datetime: <a href="#" editable-datetime="user.datetime">{{ user.datetime || 'empty' }}</a></div>
<div>Month: <a href="#" editable-month="user.month">{{ user.month || 'empty' }}</a></div>
<div>Week: <a href="#" editable-week="user.week">{{ user.week || 'empty' }}</a></div>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('Html5InputsCtrl', function($scope) {
$scope.user = {
email: '[email protected]',
tel: '123-45-67',
number: 29,
range: 10,
url: 'http://example.com',
search: 'blabla',
color: '#6a4415',
date: null,
time: '12:30',
datetime: null,
month: null,
week: null
};
});</pre>
</section>
<section id="textarea">
<h1>Textarea</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/32/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="TextareaCtrl">
<a href="#" editable-textarea="user.desc" e-rows="7" e-cols="40">
<pre>{{ user.desc || 'no description' }}</pre>
</a>
</div></div>
<pre>{{ debug["textarea"] | json }}</pre>
<p><p>To make element editable via textarea just add <code>editable-textarea</code> attribute
pointing to model in scope. You can also wrap content into <code><pre></code> tags to keep linebreaks.
Data can be submitted by <em>Ctrl + Enter</em>.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('TextareaCtrl', function($scope) {
$scope.user = {
desc: 'Awesome user \ndescription!'
};
$scope.$watch("user", function(v) { $scope.$parent.debug["textarea"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="TextareaCtrl">
<a href="#" editable-textarea="user.desc" e-rows="7" e-cols="40">
<pre>{{ user.desc || 'no description' }}</pre>
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('TextareaCtrl', function($scope) {
$scope.user = {
desc: 'Awesome user \ndescription!'
};
});</pre>
</section>
<section id="checkbox">
<h1>Checkbox</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/33/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="CheckboxCtrl">
<a href="#" editable-checkbox="user.remember" e-title="Remember?">
{{ user.remember && "Remember me!" || "Don't remember" }}
</a>
</div></div>
<pre>{{ debug["checkbox"] | json }}</pre>
<p><p>To make element editable via checkbox just add <code>editable-checkbox</code> attribute
pointing to model in scope. Set <code>e-title</code> attribute to define text shown with checkbox.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('CheckboxCtrl', function($scope) {
$scope.user = {
remember: true
};
$scope.$watch("user", function(v) { $scope.$parent.debug["checkbox"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="CheckboxCtrl">
<a href="#" editable-checkbox="user.remember" e-title="Remember?">
{{ user.remember && "Remember me!" || "Don't remember" }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('CheckboxCtrl', function($scope) {
$scope.user = {
remember: true
};
});</pre>
</section>
<section id="checklist">
<h1>Checklist</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3>
<div class="well line-example"><div ng-controller="ChecklistCtrl">
<a href="#" editable-checklist="user.status" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></div>
<pre>{{ debug["checklist"] | json }}</pre>
<p><p>To create list of checkboxes use <code>editable-checklist</code> attribute pointing to model.
Also you should define <code>e-ng-options</code> attribute to set value and display items. </p>
<p><strong>Please note</strong>, you should include <a href="http://vitalets.github.io/checklist-model">checklist-model directive</a> into your app: <code>var app = angular.module("app", [..., "checklist-model"]);</code>. </p>
<p>By default, checkboxes aligned <em>horizontally</em>. To align <em>vertically</em> just add following <strong>CSS</strong>:</p>
<pre><code>.editable-checklist label {
display: block;
}</code></pre>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('ChecklistCtrl', function($scope, $filter) {
$scope.user = {
status: [2, 3]
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'}
];
$scope.showStatus = function() {
var selected = [];
angular.forEach($scope.statuses, function(s) {
if ($scope.user.status.indexOf(s.value) >= 0) {
selected.push(s.text);
}
});
return selected.length ? selected.join(', ') : 'Not set';
};
$scope.$watch("user", function(v) { $scope.$parent.debug["checklist"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="ChecklistCtrl">
<a href="#" editable-checklist="user.status" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('ChecklistCtrl', function($scope, $filter) {
$scope.user = {
status: [2, 3]
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'}
];
$scope.showStatus = function() {
var selected = [];
angular.forEach($scope.statuses, function(s) {
if ($scope.user.status.indexOf(s.value) >= 0) {
selected.push(s.text);
}
});
return selected.length ? selected.join(', ') : 'Not set';
};
});</pre>
</section>
<section id="radiolist">
<h1>Radiolist</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3>
<div class="well line-example"><div ng-controller="RadiolistCtrl">
<a href="#" editable-radiolist="user.status" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></div>
<pre>{{ debug["radiolist"] | json }}</pre>
<p><p>To create list of radios use <code>editable-radiolist</code> attribute pointing to model.
Also you should define <code>e-ng-options</code> attribute to set value and display items.
By default, radioboxes aligned <em>horizontally</em>. To align <em>vertically</em> just add following <strong>CSS</strong>:</p>
<pre><code>.editable-radiolist label {
display: block;
}</code></pre>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('RadiolistCtrl', function($scope, $filter) {
$scope.user = {
status: 2
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'}
];
$scope.showStatus = function() {
var selected = $filter('filter')($scope.statuses, {value: $scope.user.status});
return ($scope.user.status && selected.length) ? selected[0].text : 'Not set';
};
$scope.$watch("user", function(v) { $scope.$parent.debug["radiolist"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="RadiolistCtrl">
<a href="#" editable-radiolist="user.status" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('RadiolistCtrl', function($scope, $filter) {
$scope.user = {
status: 2
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'}
];
$scope.showStatus = function() {
var selected = $filter('filter')($scope.statuses, {value: $scope.user.status});
return ($scope.user.status && selected.length) ? selected[0].text : 'Not set';
};
});</pre>
</section>
<section id="bsdate">
<h1>Date</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/23/" target="_blank" class="btn btn-info fiddle pull-right">View Bootstrap 2 jsFiddle</a>
<div class="well line-example"><div ng-controller="BsdateCtrl">
<a href="#" editable-bsdate="user.dob" e-is-open="opened.$data" e-ng-click="open($event,'$data')" e-datepicker-popup="dd-MMMM-yyyy">
{{ (user.dob | date:"dd/MM/yyyy") || 'empty' }}
</a>
</div></div>
<pre>{{ debug["bsdate"] | json }}</pre>
<p><p>Date control is implemented via <a href="http://angular-ui.github.io/bootstrap/#/datepicker">Angular-ui bootstrap datepicker</a>.<br>You should include additional <code>ui-bootstrap-tpls.min.js</code>:</p>
<pre class="prettyprint"><script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.6.0/ui-bootstrap-tpls.min.js"></script></pre>
<p>Add <code>ui.bootstrap</code> as module dependency:</p>
<pre class="prettyprint">var app = angular.module("app", ["xeditable", "ui.bootstrap"]);</pre>
<p>And set <code>editable-bsdate</code> attribute in editable element.
Other parameters can be defined via <code>e-*</code> syntax, e.g. <code>e-datepicker-popup="dd-MMMM-yyyy"</code>.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('BsdateCtrl', function($scope) {
$scope.user = {
dob: new Date(1984, 4, 15)
};
$scope.opened = {};
$scope.open = function($event, elementOpened) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened[elementOpened] = !$scope.opened[elementOpened];
};
$scope.$watch("user", function(v) { $scope.$parent.debug["bsdate"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="BsdateCtrl">
<a href="#" editable-bsdate="user.dob" e-is-open="opened.$data" e-ng-click="open($event,'$data')" e-datepicker-popup="dd-MMMM-yyyy">
{{ (user.dob | date:"dd/MM/yyyy") || 'empty' }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('BsdateCtrl', function($scope) {
$scope.user = {
dob: new Date(1984, 4, 15)
};
$scope.opened = {};
$scope.open = function($event, elementOpened) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened[elementOpened] = !$scope.opened[elementOpened];
};
});</pre>
</section>
<section id="bstime">
<h1>Time</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/34/" target="_blank" class="btn btn-info fiddle pull-right">View Bootstrap 2 jsFiddle</a>
<div class="well line-example"><div ng-controller="BstimeCtrl">
<a href="#" editable-bstime="user.time" e-show-meridian="false" e-minute-step="10">
{{ (user.time | date:"HH:mm") || 'empty' }}
</a>
</div></div>
<pre>{{ debug["bstime"] | json }}</pre>
<p><p>Time control is implemented via <a href="http://angular-ui.github.io/bootstrap/#/timepicker">Angular-ui bootstrap timepicker</a>.<br><strong>Currently it has only Bootstrap 2 version</strong>, Bootstrap 3 version is <a href="https://github.com/angular-ui/bootstrap/issues?milestone=6">in progress</a>.<br>You should include additional <code>ui-bootstrap-tpls.min.js</code>:</p>
<pre class="prettyprint"><script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.6.0/ui-bootstrap-tpls.min.js"></script></pre>
<p>Add <code>ui.bootstrap</code> as module dependency:</p>
<pre class="prettyprint">var app = angular.module("app", ["xeditable", "ui.bootstrap"]);</pre>
<p>And set <code>editable-bstime</code> attribute in editable element.
Other parameters can be defined via <code>e-*</code> syntax, e.g. <code>e-minute-step="10"</code>.</p>
<p>To get it working with <strong>Bootstrap 3</strong> you should add following css:</p>
<pre><code>/* temporary workaround for display editable-bstime in bs3 - up/down symbols not shown */
.editable-bstime .editable-input i.icon-chevron-up:before {
content: '\e113';
}
.editable-bstime .editable-input i.icon-chevron-down:before {
content: '\e114';
}
.editable-bstime .editable-input i.icon-chevron-up,
.editable-bstime .editable-input i.icon-chevron-down {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
-webkit-font-smoothing: antialiased;
font-style: normal;
font-weight: normal;
line-height: 1;
}</code></pre>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('BstimeCtrl', function($scope) {
$scope.user = {
time: new Date(1984, 4, 15, 19, 20)
};
$scope.$watch("user", function(v) { $scope.$parent.debug["bstime"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="BstimeCtrl">
<a href="#" editable-bstime="user.time" e-show-meridian="false" e-minute-step="10">
{{ (user.time | date:"HH:mm") || 'empty' }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('BstimeCtrl', function($scope) {
$scope.user = {
time: new Date(1984, 4, 15, 19, 20)
};
});</pre>
</section>
<section id="combodate">
<h1>DateTime</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3>
<div class="well line-example"><div ng-controller="CombodateCtrl">
<a href="#" editable-combodate="user.dob">
{{ (user.dob | date:"medium") || 'empty' }}
</a>
</div></div>
<pre>{{ debug["combodate"] | json }}</pre>
<p><p>You should include additional <code>moment.js</code>:</p>
<p>And set <code>editable-combodate</code> attribute in editable element.
Custom options supported by <a href="https://vitalets.github.io/combodate/">Combodate</a> can be provided via <code>e-*</code> syntax, e.g. <code>e-min-year="2015"</code>.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('CombodateCtrl', function($scope) {
$scope.user = {
dob: new Date(1984, 4, 15)
};
$scope.$watch("user", function(v) { $scope.$parent.debug["combodate"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="CombodateCtrl">
<a href="#" editable-combodate="user.dob">
{{ (user.dob | date:"medium") || 'empty' }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('CombodateCtrl', function($scope) {
$scope.user = {
dob: new Date(1984, 4, 15)
};
});</pre>
</section>
<section id="typeahead">
<h1>Typeahead</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/46/" target="_blank" class="btn btn-info fiddle pull-right">View Bootstrap 2 jsFiddle</a>
<div class="well line-example"><div ng-controller="TypeaheadCtrl">
<a href="#" editable-text="user.state" e-typeahead="state for state in states | filter:$viewValue | limitTo:8">
{{ user.state || 'empty' }}
</a>
</div></div>
<pre>{{ debug["typeahead"] | json }}</pre>
<p><p>Typeahead control is implemented via <a href="http://angular-ui.github.io/bootstrap/#/typeahead">Angular-ui bootstrap typeahead</a>.<br>Basically it is normal <code>editable-text</code> control with additional <code>e-typeahead</code> attributes.<br>You should include additional <code>ui-bootstrap-tpls.min.js</code>:</p>
<pre class="prettyprint"><script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.6.0/ui-bootstrap-tpls.min.js"></script></pre>
<p>Then add <code>ui.bootstrap</code> as module dependency:</p>
<pre class="prettyprint">var app = angular.module("app", ["xeditable", "ui.bootstrap"]);</pre>
<p>And finally set <code>editable-text</code> attribute pointing to model and <code>e-typeahead</code> attribute pointing to typeahead items.
Other parameters can be defined via <code>e-typeahead-*</code> syntax, e.g. <code>e-typeahead-wait-ms="100"</code>.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('TypeaheadCtrl', function($scope) {
$scope.user = {
state: 'Arizona'
};
$scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
$scope.$watch("user", function(v) { $scope.$parent.debug["typeahead"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="TypeaheadCtrl">
<a href="#" editable-text="user.state" e-typeahead="state for state in states | filter:$viewValue | limitTo:8">
{{ user.state || 'empty' }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('TypeaheadCtrl', function($scope) {
$scope.user = {
state: 'Arizona'
};
$scope.states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Dakota', 'North Carolina', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
});</pre>
</section>
<section id="text-customize">
<h1>Customize input</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/26/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="TextCustomizeCtrl">
<a href="#" editable-text="user.name" e-style="color: green" e-required e-placeholder="Enter name">
{{ (user.name || 'empty') | uppercase }}
</a>
</div></div>
<pre>{{ debug["text-customize"] | json }}</pre>
<p><p>To define attributes for input (e.g. <code>style</code> or <code>placeholder</code>) you can define them
on the original element with <code>e-*</code> prefix (e.g. <code>e-style</code> or <code>e-placeholder</code>).
When input will appear these attributes will be transfered to it.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('TextCustomizeCtrl', function($scope) {
$scope.user = {
name: 'awesome user'
};
$scope.$watch("user", function(v) { $scope.$parent.debug["text-customize"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="TextCustomizeCtrl">
<a href="#" editable-text="user.name" e-style="color: green" e-required e-placeholder="Enter name">
{{ (user.name || 'empty') | uppercase }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('TextCustomizeCtrl', function($scope) {
$scope.user = {
name: 'awesome user'
};
});</pre>
</section>
<section id="text-btn">
<h1>Trigger manually</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/27/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="TextBtnCtrl">
<span editable-text="user.name" e-form="textBtnForm">
{{ user.name || 'empty' }}
</span>
<button class="btn btn-default" ng-click="textBtnForm.$show()" ng-hide="textBtnForm.$visible">
edit
</button>
</div></div>
<pre>{{ debug["text-btn"] | json }}</pre>
<p><p>To trigger edit-in-place by external button you should define <code>e-form</code> attribute.
Value of it is the name of variable to be created in scope that allows you to show / hide editor manually.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('TextBtnCtrl', function($scope) {
$scope.user = {
name: 'awesome user'
};
$scope.$watch("user", function(v) { $scope.$parent.debug["text-btn"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="TextBtnCtrl">
<span editable-text="user.name" e-form="textBtnForm">
{{ user.name || 'empty' }}
</span>
<button class="btn btn-default" ng-click="textBtnForm.$show()" ng-hide="textBtnForm.$visible">
edit
</button>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('TextBtnCtrl', function($scope) {
$scope.user = {
name: 'awesome user'
};
});</pre>
</section>
<section id="select-nobuttons">
<h1>Hide buttons</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/31/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="SelectNobuttonsCtrl">
<a href="#" editable-select="user.status" buttons="no" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></div>
<pre>{{ debug["select-nobuttons"] | json }}</pre>
<p><p>To hide <em>Ok</em> and <em>Cancel</em> buttons you may set <code>buttons="no"</code> attribute.
New value will be saved automatically after change.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('SelectNobuttonsCtrl', function($scope, $filter) {
$scope.user = {
status: 2
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'},
{value: 4, text: 'status4'}
];
$scope.showStatus = function() {
var selected = $filter('filter')($scope.statuses, {value: $scope.user.status});
return ($scope.user.status && selected.length) ? selected[0].text : 'Not set';
};
$scope.$watch("user", function(v) { $scope.$parent.debug["select-nobuttons"]=v; }); });</script>
<h3>html</h3>
<pre class="prettyprint ng-non-bindable"><div ng-controller="SelectNobuttonsCtrl">
<a href="#" editable-select="user.status" buttons="no" e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></pre>
<h3>controller.js</h3>
<pre class="prettyprint">app.controller('SelectNobuttonsCtrl', function($scope, $filter) {
$scope.user = {
status: 2
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'},
{value: 4, text: 'status4'}
];
$scope.showStatus = function() {
var selected = $filter('filter')($scope.statuses, {value: $scope.user.status});
return ($scope.user.status && selected.length) ? selected[0].text : 'Not set';
};
});</pre>
</section>
<section id="select-multiple">
<h1>Select multiple</h1>
<!-- watch change of user to update rootScope for debugging-->
<h3>demo</h3><a href="http://jsfiddle.net/NfPcH/30/" target="_blank" class="btn btn-info fiddle pull-right">jsFiddle</a>
<div class="well line-example"><div ng-controller="SelectMultipleCtrl">
<a href="#" editable-select="user.status" e-multiple e-ng-options="s.value as s.text for s in statuses">
{{ showStatus() }}
</a>
</div></div>
<pre>{{ debug["select-multiple"] | json }}</pre>
<p><p>Just define <code>e-multiple</code> attribute that will be transfered to select as <code>multiple</code>.</p>
</p>
<!--script(src=dir+'/controller.js')-->
<script>app.controller('SelectMultipleCtrl', function($scope, $filter) {
$scope.user = {
status: [2, 4]
};
$scope.statuses = [
{value: 1, text: 'status1'},
{value: 2, text: 'status2'},
{value: 3, text: 'status3'},
{value: 4, text: 'status4'}
];
$scope.showStatus = function() {
var selected = [];