@@ -21,6 +21,7 @@ class AngularBootstrap {
21
21
return lastRandom;
22
22
};
23
23
$rootScope['people' ] = ["James" , "Misko" ];
24
+ $rootScope['objs' ] = [{'v' : 'v1' }, {'v' : 'v2' }];
24
25
25
26
var template = $compile.call (topElt);
26
27
template.call (topElt).attach ($rootScope);
@@ -30,67 +31,68 @@ class AngularBootstrap {
30
31
}
31
32
}
32
33
33
- class TabsController implements Controller {
34
+ class BookController implements Controller {
34
35
Scope $scope;
35
- List panes;
36
- var selectedPanes = new Expando <dom.Node >();
36
+ List chapters;
37
37
38
- MainController (Scope this .$scope) {
39
- panes = $scope.panes = [];
38
+ BookController (Scope this .$scope) {
39
+ $scope.greeting = "TabController" ;
40
+ chapters = [];
41
+ $scope.chapters = chapters;
40
42
41
- $scope.selected = (pane ) {
42
- panes .forEach ((p) {
43
- selectedPanes[p][ ' selected' ] = false ;
43
+ $scope.selected = (chapterScope ) {
44
+ chapters .forEach ((p) {
45
+ p[ " selected" ] = false ;
44
46
});
45
- selectedPanes[pane][ ' selected' ] = true ;
47
+ chapterScope[ " selected" ] = true ;
46
48
};
47
49
}
48
50
49
- addPane (dom. Node pane ) {
50
- if (panes .length == 0 ) { $scope.selected (pane ); }
51
- panes .add (pane );
51
+ addChapter ( var chapterScope ) {
52
+ if (chapters .length == 0 ) { ( $scope.selected)(chapterScope ); }
53
+ chapters .add (chapterScope );
52
54
}
53
55
}
54
56
55
- class TabsAttrDirective {
56
- static var $transclude = "true" ;
57
- static String $template = '<div class="tabbable">Shadow' +
58
- '<ul class="nav nav-tabs">' +
59
- '<li ng-repeat="pane in panes" ng-class="{active:pane.selected}">' +
60
- '<a href="" ng-click="select(pane)">{{pane.title}}</a>' +
61
- '</li>' +
57
+ class BookAttrDirective {
58
+ static var $controller = BookController ;
59
+ static String $template =
60
+ '<div>Shadow backed template. Greeting from the controller: <span ng-bind="greeting"></span>' +
61
+ '<h2>Table of Contents</h2><ul class="nav nav-tabs">' +
62
+ ' <li ng-repeat="chapter in chapters" ng-bind="chapter.title"></li>' +
62
63
'</ul>' +
63
- '<content class="tab-content" ng-transclude>CONTENT </content>' +
64
+ '<content> </content>' +
64
65
'</div>' ;
65
- // static String $template = '<div>Hello shaddow</div>';
66
- BlockList blockList;
67
66
67
+ attach (Scope scope) {}
68
+ }
68
69
69
- TabsAttrDirective (BlockList this .blockList,
70
- dom.Element element) {
71
- dom.ShadowRoot shadow = element.createShadowRoot ();
72
-
73
-
74
- print ("tab attr: ${element .text }" );
75
- print ("shadow: ${shadow .text }" );
76
-
77
- }
70
+ class ChapterAttrDirective {
71
+ static var $require = "^[book]" ;
72
+ BookController controller;
73
+ dom.Element element;
74
+ ChapterAttrDirective (dom.Element this .element, Controller this .controller);
78
75
79
76
attach (Scope scope) {
80
- print ("tab attach" );
77
+ // automatic scope management isn't implemented yet.
78
+ var child = scope.$new ();
79
+ child.title = element.attributes['title' ];
80
+ controller.addChapter (child);
81
81
}
82
82
}
83
83
84
84
main () {
85
85
// Set up the Angular directives.
86
86
var module = new Module ();
87
+ module.value (Expando , new Expando ());
87
88
angularModule (module);
88
89
Injector injector = new Injector ([module]);
89
90
Directives directives = injector.get (Directives );
90
91
directives.register (NgBindAttrDirective );
91
92
directives.register (NgRepeatAttrDirective );
92
93
directives.register (NgShadowDomAttrDirective );
93
- directives.register (TabsAttrDirective );
94
+ directives.register (BookAttrDirective );
95
+ directives.register (ChapterAttrDirective );
94
96
95
97
injector.get (AngularBootstrap )();
96
98
0 commit comments