File tree Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,12 @@ <h1 class="page-header">Scroller Examples</h1>
111
111
</ li >
112
112
< li >
113
113
< a href ="controllerAs/controllerAs.html ">
114
- controllerAs syntax
114
+ "Controller as" syntax
115
+ </ a >
116
+ </ li >
117
+ < li >
118
+ < a href ="insideDirective/insideDirective.html ">
119
+ Inside the directive (+ "Controller as" syntax)
115
120
</ a >
116
121
</ li >
117
122
< li >
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 directive</ 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 ="insideDirective.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 the directive</ h1 >
19
+
20
+ < div class ="description ">
21
+ This sample demonstrates encapsulation of the ui-scroll directive inside another custom directive wich has it's own controller and wich uses "Controller As" syntax in it's template.
22
+ </ div >
23
+
24
+ < my-dir > </ my-dir >
25
+
26
+ </ div >
27
+
28
+ </ body >
29
+ </ html >
Original file line number Diff line number Diff line change
1
+ angular . module ( 'application' , [ 'ui.scroll' , 'ui.scroll.jqlite' ] )
2
+ . directive ( 'myDir' , function ( ) {
3
+ return {
4
+ restrict : 'E' ,
5
+ controllerAs : 'ctrl' ,
6
+ template :
7
+ '<div ui-scroll-viewport class="viewport" ng-if="ctrl.show">' +
8
+ '<div class="item" ui-scroll="item in ctrl" adapter="ctrl.scrollAdapter">' +
9
+ '<div ng-click="ctrl.update(item.id)">{{item.name}}</div>' +
10
+ '</div>' +
11
+ '</div>' ,
12
+ controller : function ( $timeout ) {
13
+ var ctrl = this ;
14
+ ctrl . show = true ;
15
+ ctrl . get = function ( index , count , success ) {
16
+ $timeout ( function ( ) {
17
+ var result = [ ] ;
18
+ for ( var i = index ; i <= index + count - 1 ; i ++ ) {
19
+ result . push ( {
20
+ id : i ,
21
+ name : "item #" + i
22
+ } ) ;
23
+ }
24
+ success ( result ) ;
25
+ } , 100 ) ;
26
+ }
27
+ ctrl . update = function ( id ) {
28
+ return ctrl . scrollAdapter . applyUpdates ( function ( item ) {
29
+ if ( item . id === id ) {
30
+ item . name += " *" ;
31
+ }
32
+ } ) ;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ ) ;
You can’t perform that action at this time.
0 commit comments