diff --git a/public/docs/_examples/attribute-directives/dart/lib/app_component.dart b/public/docs/_examples/attribute-directives/dart/lib/app_component.dart new file mode 100644 index 0000000000..3e580212fb --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/lib/app_component.dart @@ -0,0 +1,13 @@ +// #docregion +library attribute_directives.app_component; + +import 'package:angular2/angular2.dart'; +import 'package:attribute_directives/highlight_directive.dart'; + +@Component( + selector: 'my-app', + templateUrl: 'app_component.html', + directives: const [Highlight]) +class AppComponent { + String color; +} diff --git a/public/docs/_examples/attribute-directives/dart/lib/app_component.html b/public/docs/_examples/attribute-directives/dart/lib/app_component.html new file mode 100644 index 0000000000..b8fd63c8e3 --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/lib/app_component.html @@ -0,0 +1,20 @@ + + +

My First Attribute Directive

+

Pick a highlight color

+
+ Green + Yellow + Cyan +
+ +

Highlight me!

+ + + + +

+Highlight me too! +

+ + diff --git a/public/docs/_examples/attribute-directives/dart/lib/app_component_1.html b/public/docs/_examples/attribute-directives/dart/lib/app_component_1.html new file mode 100644 index 0000000000..b76a260a1a --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/lib/app_component_1.html @@ -0,0 +1,3 @@ + +

My First Attribute Directive

+Highlight me! diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart new file mode 100644 index 0000000000..4dfe4b519e --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive.dart @@ -0,0 +1,55 @@ +// #docplaster +// #docregion full +library attribute_directives.highlight_directive; + +import 'package:angular2/angular2.dart'; + +@Directive(selector: '[my-highlight]', host: const { + '(mouseenter)': 'onMouseEnter()', + '(mouseleave)': 'onMouseLeave()' +}) +// #docregion class-1 +class Highlight { + // #enddocregion class-1 +// #enddocregion full + /* +// #docregion highlight + @Input() myHighlight: string; +// #enddocregion highlight + */ +// #docregion full +// #docregion class-1 +// #docregion color + @Input('my-highlight') String highlightColor; +// #enddocregion color + + String _defaultColor = 'red'; + // #enddocregion class-1 + // #docregion defaultColor + @Input() set defaultColor(String colorName) { + _defaultColor = (colorName ?? _defaultColor); + } + // #enddocregion defaultColor +// #docregion class-1 + + final Renderer _renderer; + final ElementRef _element; + +// #docregion mouse-enter + onMouseEnter() { + _highlight(highlightColor ?? _defaultColor); + } + +// #enddocregion mouse-enter + onMouseLeave() { + _highlight(null); + } + + void _highlight(String color) { + _renderer.setElementStyle(_element, 'background-color', color); + } + + Highlight(this._element, this._renderer); +} +// #enddocregion class-1 +// #enddocregion full diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart new file mode 100644 index 0000000000..468f2b991b --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_1.dart @@ -0,0 +1,12 @@ +// #docregion +library attribute_directives.highlight_directive; + +import 'package:angular2/angular2.dart'; + +@Directive(selector: '[my-highlight]') +class Highlight { + Highlight(ElementRef element, Renderer renderer) { + //el.nativeElement.style.backgroundColor = 'yellow'; + renderer.setElementStyle(element, 'background-color', 'yellow'); + } +} diff --git a/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart new file mode 100644 index 0000000000..00d92491ea --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/lib/highlight_directive_2.dart @@ -0,0 +1,35 @@ +// #docregion +library attribute_directives.highlight_directive; + +import 'package:angular2/angular2.dart'; + +@Directive(selector: '[my-highlight]', +// #docregion host + host: const { + '(mouseenter)': 'onMouseEnter()', + '(mouseleave)': 'onMouseLeave()' + } +// #enddocregion host + ) +class Highlight { + final Renderer _renderer; + final ElementRef _element; +// #docregion mouse-methods + onMouseEnter() { + _highlight("yellow"); + } + + onMouseLeave() { + _highlight(null); + } + // #enddocregion mouse-methods + + void _highlight(String color) { + _renderer.setElementStyle(_element, 'background-color', color); + } + +// #docregion ctor + Highlight(this._element, this._renderer); +// #enddocregion ctor +} +// #enddocregion diff --git a/public/docs/_examples/attribute-directives/dart/pubspec.yaml b/public/docs/_examples/attribute-directives/dart/pubspec.yaml new file mode 100644 index 0000000000..cf2b400594 --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/pubspec.yaml @@ -0,0 +1,10 @@ +name: attribute_directives +description: Attribute Directives +version: 0.0.1 +dependencies: + angular2: 2.0.0-beta.0 + browser: ^0.10.0 +transformers: +- angular2: + platform_directives: 'package:angular2/src/common/directives.dart#CORE_DIRECTIVES' + entry_points: web/main.dart diff --git a/public/docs/_examples/attribute-directives/dart/web/index.html b/public/docs/_examples/attribute-directives/dart/web/index.html new file mode 100644 index 0000000000..a5bd588548 --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/web/index.html @@ -0,0 +1,13 @@ + + + + + Attribute Directives + + + + + + loading... + + diff --git a/public/docs/_examples/attribute-directives/dart/web/main.dart b/public/docs/_examples/attribute-directives/dart/web/main.dart new file mode 100644 index 0000000000..ce74487a47 --- /dev/null +++ b/public/docs/_examples/attribute-directives/dart/web/main.dart @@ -0,0 +1,7 @@ +// #docregion +import 'package:angular2/bootstrap.dart'; +import 'package:attribute_directives/app_component.dart'; + +main() { + bootstrap(AppComponent); +} diff --git a/public/docs/_examples/attribute-directives/dart/web/style.css b/public/docs/_examples/attribute-directives/dart/web/style.css new file mode 100644 index 0000000000..e69de29bb2