File tree Expand file tree Collapse file tree 3 files changed +80
-2
lines changed Expand file tree Collapse file tree 3 files changed +80
-2
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,11 @@ <h1 class="page-header">Scroller Examples</h1>
119
119
Inside the directive (+ "Controller as" syntax)
120
120
</ a >
121
121
</ li >
122
+ < li >
123
+ < a href ="insideComponent/insideComponent.html ">
124
+ Inside the es6 component
125
+ </ a >
126
+ </ li >
122
127
< li >
123
128
< a href ="adapterOnController/adapterOnController.html ">
124
129
Append on controller
@@ -153,7 +158,7 @@ <h1 class="page-header">Scroller Examples</h1>
153
158
< a href ="grid-layout-manipulations/grid-layout-manipulations.html ">
154
159
Grid layout manipulations
155
160
</ a >
156
- </ li >
161
+ </ li >
157
162
< li >
158
163
< a href ="grid-dnd-sort/grid-dnd-sort.html ">
159
164
Grid drag and drop sort, moveBefore
@@ -177,4 +182,4 @@ <h1 class="page-header">Scroller Examples</h1>
177
182
178
183
</ div >
179
184
</ body >
180
- </ html >
185
+ </ html >
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < title > Inside es6 component</ title >
6
+ < script src ="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.js "> </ script >
7
+ < script src ="../../dist/ui-scroll.js "> </ script >
8
+ < script src ="../../dist/ui-scroll-jqlite.js "> </ script >
9
+ < script src ="insideComponent.js "> </ script >
10
+ < link rel ="stylesheet " href ="../css/style.css " type ="text/css "/>
11
+ </ head >
12
+ < body ng-app ="application ">
13
+
14
+ < div class ="cont cont-global ">
15
+
16
+ < a class ="back " href ="../index.html "> browse other examples</ a >
17
+
18
+ < h1 class ="page-header page-header-exapmle "> Scroller inside ES6 Component</ h1 >
19
+
20
+ < div class ="description ">
21
+ This sample demonstrates encapsulation of the ui-scroll directive inside some custom component (Angular 1.5+). The controller of this Component is implemented as ES6 class. Note that this demo might not work in old browsers which don't support ES6 classes.
22
+ </ div >
23
+
24
+ < my-component > </ my-component >
25
+
26
+ </ div >
27
+
28
+ </ body >
29
+ </ html >
Original file line number Diff line number Diff line change
1
+ ( function ( angular ) {
2
+
3
+ class Ctrl {
4
+ constructor ( $timeout ) {
5
+ this . timeout = $timeout ;
6
+ this . show = true ;
7
+ }
8
+
9
+ get ( index , count , success ) {
10
+ this . timeout ( function ( ) {
11
+ var result = [ ] ;
12
+ for ( var i = index ; i <= index + count - 1 ; i ++ ) {
13
+ result . push ( {
14
+ id : i ,
15
+ name : "item #" + i
16
+ } ) ;
17
+ }
18
+ success ( result ) ;
19
+ } , 100 ) ;
20
+ }
21
+
22
+ update ( id ) {
23
+ return this . scrollAdapter . applyUpdates ( function ( item ) {
24
+ if ( item . id === id ) {
25
+ item . name += " *" ;
26
+ }
27
+ } ) ;
28
+ }
29
+ }
30
+
31
+ angular
32
+ . module ( 'application' , [ 'ui.scroll' , 'ui.scroll.jqlite' ] )
33
+ . component ( 'myComponent' , {
34
+ controllerAs : 'ctrl' ,
35
+ template :
36
+ '<div ui-scroll-viewport class="viewport" ng-if="ctrl.show">' +
37
+ '<div class="item" ui-scroll="item in ctrl" adapter="ctrl.scrollAdapter">' +
38
+ '<div ng-click="ctrl.update(item.id)">{{item.name}}</div>' +
39
+ '</div>' +
40
+ '</div>' ,
41
+ controller : Ctrl
42
+ } ) ;
43
+
44
+ } ) ( angular ) ;
You can’t perform that action at this time.
0 commit comments