Also update dart_to_js_script_rewriter dependency to ^1.0.1, and change most angular2.dart imports to be core.dart instead. The pipes example broke without the angular2.dart import, so I let it be. The server-communication sample has never worked for me, so I changed it but might have broken it further. closes #1007
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
// #docplaster
 | 
						|
// #docregion full
 | 
						|
import 'package:angular2/core.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 ElementRef _element;
 | 
						|
 | 
						|
// #docregion mouse-enter
 | 
						|
  onMouseEnter() {
 | 
						|
    _highlight(highlightColor ?? _defaultColor);
 | 
						|
  }
 | 
						|
 | 
						|
// #enddocregion mouse-enter
 | 
						|
  onMouseLeave() {
 | 
						|
    _highlight(null);
 | 
						|
  }
 | 
						|
 | 
						|
  void _highlight(String color) {
 | 
						|
    _element.nativeElement.style.backgroundColor = color;
 | 
						|
  }
 | 
						|
 | 
						|
  Highlight(this._element);
 | 
						|
}
 | 
						|
// #enddocregion class-1
 | 
						|
// #enddocregion full
 |