Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: third_party/pkg/angular/demo/web/main.dart

Issue 148453003: Updating Angular version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 import 'dart:html' as dom;
2 import 'dart:math' as math;
3
4 import 'package:angular/angular.dart';
5 import 'package:di/di.dart';
6
7 class BookController {
8 Scope $scope;
9 List chapters;
10
11 attach(Scope scope) {
12 $scope = scope;
13
14 $scope.greeting = 'TabController';
15 chapters = [];
16 $scope.chapters = chapters;
17
18 $scope.selected = (chapterScope) {
19 chapters.forEach((p) {
20 p['selected'] = false;
21 });
22 chapterScope['selected'] = true;
23 };
24 }
25
26 addChapter(var chapterScope) {
27 if (chapters.length == 0) { ($scope.selected)(chapterScope); }
28 chapters.add(chapterScope);
29 }
30 }
31
32 class BookComponent {
33 BookController controller;
34 BookComponent(BookController this.controller);
35
36 static String $templateUrl = 'book.html';
37 static String $cssUrl = 'book.css';
38
39 attach(Scope scope) {
40 controller.attach(scope);
41 }
42 }
43
44 class ChapterDirective {
45 BookController controller;
46 dom.Element element;
47 ChapterDirective(dom.Element this.element, BookController this.controller);
48
49 attach(Scope scope) {
50 // automatic scope management isn't implemented yet.
51 var child = scope.$new();
52 child.title = element.attributes['title'];
53 controller.addChapter(child);
54 }
55 }
56
57 @NgDirective(
58 selector: '[main-controller]'
59 )
60 class MainController {
61
62 String _random = 'Random: ${new math.Random().nextInt(100)}';
63
64 MainController(Scope scope) {
65 scope['greeting'] = 'Hello world!';
66 scope['people'] = ['James', 'Misko'];
67 scope['objs'] = [{'v': 'v1'}, {'v': 'v2'}];
68 scope['random'] = () {
69 return _random;
70 };
71 }
72 }
73
74 main() {
75 // Set up the Angular directives.
76 var module = new Module()
77 ..type(BookComponent)
78 ..type(ChapterDirective)
79 ..type(MainController);
80
81 ngBootstrap(module:module);
82 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/demo/web/index.html ('k') | third_party/pkg/angular/demo/web/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698