2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
import {Attribute, Component, Directive, Pipe} from '@angular/core';
|
2015-11-30 11:28:54 -05:00
|
|
|
|
2016-08-10 21:21:28 -04:00
|
|
|
class CustomDirective {};
|
2015-11-30 11:28:54 -05:00
|
|
|
|
|
|
|
// #docregion component
|
2016-08-19 15:51:01 -04:00
|
|
|
@Component({selector: 'greet', template: 'Hello {{name}}!'})
|
2015-11-30 11:28:54 -05:00
|
|
|
class Greet {
|
|
|
|
name: string = 'World';
|
|
|
|
}
|
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
// #docregion attributeFactory
|
|
|
|
@Component({selector: 'page', template: 'Title: {{title}}'})
|
|
|
|
class Page {
|
|
|
|
title: string;
|
|
|
|
constructor(@Attribute('title') title: string) { this.title = title; }
|
|
|
|
}
|
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
// #docregion attributeMetadata
|
|
|
|
@Directive({selector: 'input'})
|
|
|
|
class InputAttrDirective {
|
2016-02-11 20:01:17 -05:00
|
|
|
constructor(@Attribute('type') type: string) {
|
2015-11-30 11:28:54 -05:00
|
|
|
// type would be 'text' in this example
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
// #docregion directive
|
|
|
|
@Directive({selector: 'input'})
|
|
|
|
class InputDirective {
|
|
|
|
constructor() {
|
|
|
|
// Add some logic.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
// #docregion pipe
|
|
|
|
@Pipe({name: 'lowercase'})
|
|
|
|
class Lowercase {
|
2016-02-11 20:01:17 -05:00
|
|
|
transform(v: string, args: any[]) { return v.toLowerCase(); }
|
2015-11-30 11:28:54 -05:00
|
|
|
}
|
|
|
|
// #enddocregion
|