Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit a168174

Browse files
committed
docs(template-syntax): Remove this where it is not needed. Use string interpolation where it make sense. Fix Library syntax for little_hero. Add #docregion comment to all relevant files. Move const List to inline List in class declaration and set currentHero in constructor. Create constructor for AppComponent class.
1 parent 9456757 commit a168174

File tree

12 files changed

+50
-26
lines changed

12 files changed

+50
-26
lines changed

public/docs/_examples/template-syntax/dart/lib/app_component.dart

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docregion
12
library template_syntax.app_component;
23

34
import 'dart:html';
@@ -11,22 +12,10 @@ import 'package:template_syntax/loop_back_component.dart';
1112
import 'package:template_syntax/key_up_components.dart';
1213
import 'package:template_syntax/little_hero.dart';
1314

14-
List<Hero> _MockHeroes = [
15-
new Hero('Hercules',
16-
lastName: 'Son of Zeus',
17-
birthdate: new DateTime(1970, 1, 25),
18-
url: 'http://www.imdb.com/title/tt0065832/',
19-
rate: 325),
20-
new Hero('eenie', lastName: 'toe'),
21-
new Hero('Meanie', lastName: 'Toe'),
22-
new Hero('Miny', lastName: 'Toe'),
23-
new Hero('Moe', lastName: 'Toe')
24-
];
25-
2615
enum _Color { Red, Green, Blue }
2716

28-
@Component(selector: 'my-app')
29-
@View(
17+
@Component(
18+
selector: 'my-app',
3019
templateUrl: 'my-app.html',
3120
directives: const [
3221
CORE_DIRECTIVES,
@@ -41,10 +30,19 @@ enum _Color { Red, Green, Blue }
4130
LittleHeroComponent,
4231
])
4332
class AppComponent {
44-
List<Hero> heroes = _MockHeroes;
45-
Hero currentHero = _MockHeroes.first;
33+
List<Hero> heroes = [
34+
new Hero('Hercules',
35+
lastName: 'Son of Zeus',
36+
birthdate: new DateTime(1970, 1, 25),
37+
url: 'http://www.imdb.com/title/tt0065832/',
38+
rate: 325),
39+
new Hero('eenie', lastName: 'toe'),
40+
new Hero('Meanie', lastName: 'Toe'),
41+
new Hero('Miny', lastName: 'Toe'),
42+
new Hero('Moe', lastName: 'Toe')
43+
];
44+
Hero currentHero;
4645
Hero nullHero = null; // or undefined
47-
4846
bool isUnchanged = true;
4947
bool isSpecial = true;
5048
bool isActive = false;
@@ -61,12 +59,16 @@ class AppComponent {
6159
'https://angular.io/resources/images/logos/standard/shield-large.png';
6260
Map product = {'name': 'frimfram', 'price': 42};
6361

62+
AppComponent() {
63+
currentHero = heroes.first;
64+
}
65+
6466
colorToggle() {
6567
color = color == _Color.Red ? _Color.Blue : _Color.Red;
6668
}
6769

6870
getStyles(Element el) {
69-
var showStyles = this.setStyles();
71+
var showStyles = setStyles();
7072
return JSON.encode(showStyles);
7173
}
7274

@@ -91,7 +93,7 @@ class AppComponent {
9193
}
9294

9395
setLastName(event) {
94-
this.currentHero.lastName = event;
96+
currentHero.lastName = event;
9597
}
9698

9799
setClasses() {
@@ -120,3 +122,4 @@ class AppComponent {
120122
}
121123
}
122124
}
125+
// #enddocregion

public/docs/_examples/template-syntax/dart/lib/click_me_component.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docregion
12
library template_syntax.click_me_component;
23

34
import 'dart:html';
@@ -11,3 +12,4 @@ class ClickMeComponent {
1112
window.alert('You are my hero!');
1213
}
1314
}
15+
// #enddocregion

public/docs/_examples/template-syntax/dart/lib/hero.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docregion
12
library template_syntax.hero;
23

34
class Hero {
@@ -10,8 +11,9 @@ class Hero {
1011
int rate = 100;
1112

1213
Hero(this.firstName, {this.lastName, this.birthdate, this.url, this.rate}) {
13-
this.id = _nextId++;
14+
id = _nextId++;
1415
}
1516

16-
String get fullName => firstName + ' ' + lastName;
17+
String get fullName => '$firstName $lastName';
1718
}
19+
// #enddocregion

public/docs/_examples/template-syntax/dart/lib/hero_detail_component.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docregion
12
library template_syntax.hero_detail_component;
23

34
import 'package:angular2/angular2.dart';
@@ -25,3 +26,4 @@ class HeroDetailComponent {
2526
deleted.add(hero);
2627
}
2728
}
29+
// #enddocregion

public/docs/_examples/template-syntax/dart/lib/key_up_components.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docregion
12
library template_syntax.key_up_components;
23

34
import 'package:angular2/angular2.dart';
@@ -47,3 +48,4 @@ class KeyUpComponentV3 {
4748
class KeyUpComponentV4 {
4849
String values = '';
4950
}
51+
// #enddocregion

public/docs/_examples/template-syntax/dart/lib/little_hero.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
library template_syntax.littleHero;
1+
// #docregion
2+
library template_syntax.little_hero;
23

34
import 'package:angular2/angular2.dart';
45
import 'package:template_syntax/hero.dart';
@@ -12,3 +13,4 @@ class LittleHeroComponent {
1213
@Input()
1314
Type hero = Hero;
1415
}
16+
// #enddocregion

public/docs/_examples/template-syntax/dart/lib/little_tour.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// #docregion
12
library template_syntax.little_tour;
23

34
import 'dart:html';
@@ -24,3 +25,4 @@ class LittleTourComponent {
2425
}
2526
}
2627
}
28+
// #enddocregion
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// #docregion
12
library template_syntax.loop_back_component;
23

34
import 'package:angular2/angular2.dart';
45

56
@Component(selector: 'loop-back')
67
@View(template: '''<input #box (keyup)="0"> <p>{{box.value}}</p>''')
78
class LoopBackComponent {}
9+
// #enddocregion

public/docs/_examples/template-syntax/dart/lib/my-app.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- #docregion -->
12
<!-- Interpolation and expressions</h1> -->
23
<h3>My First Angular Application</h3>
34
<h3>
@@ -123,13 +124,14 @@ <h4>keyup loop-back component</h4>
123124

124125
<!-- attribute binding -->
125126
<hr>
126-
<!--Template parse errors:-->
127-
<!--Can't bind to 'colspan' since it isn't a known native property-->
128-
<tr><td colspan="{{1+1}}">Three-Four</td></tr>
127+
129128

130129
<!-- create and set a span attribute -->
131130
<table border=1>
132131
<tr><td>One</td><td>Two</td></tr>
132+
<!--Template parse errors:-->
133+
<!--Can't bind to 'colspan' since it isn't a known native property-->
134+
<tr><td colspan="{{1+1}}">Three-Four</td></tr>
133135

134136
<!-- ERROR: There is no `colspan` property to set!
135137
<tr><td colspan="{{1+1}}">Three-Four</td></tr>
@@ -400,3 +402,4 @@ <h2>Enums in bindings </h2>
400402
<p>The name of the Color.Red enum is {{color}}</p>
401403
<p>The current color number is {{color.index}}</p>
402404
<p><button [style.color]="color" (click)="colorToggle()">Enum Toggle</button>
405+
<!-- #docregion -->

public/docs/_examples/template-syntax/dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: template_syntax
22
description: Template Syntax
33
version: 0.0.1
44
dependencies:
5-
angular2: 2.0.0-alpha.46
5+
angular2: 2.0.0-alpha.47
66
browser: ^0.10.0
77
transformers:
88
- angular2:

0 commit comments

Comments
 (0)