2016-06-23 09:47:54 -07: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-09 13:23:29 -07:00
|
|
|
import * as common from '@angular/common';
|
2016-09-06 07:49:38 -07:00
|
|
|
import {CUSTOM_ELEMENTS_SCHEMA, Component, Directive, EventEmitter, Inject, NgModule, OpaqueToken, Output} from '@angular/core';
|
|
|
|
import {Observable} from 'rxjs/Observable';
|
2016-04-30 16:13:03 -07:00
|
|
|
|
2016-06-13 15:56:51 -07:00
|
|
|
import {wrapInArray} from './funcs';
|
|
|
|
|
2016-04-30 16:13:03 -07:00
|
|
|
export const SOME_OPAQUE_TOKEN = new OpaqueToken('opaqueToken');
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'comp-providers',
|
|
|
|
template: '',
|
|
|
|
providers: [
|
|
|
|
{provide: 'strToken', useValue: 'strValue'},
|
|
|
|
{provide: SOME_OPAQUE_TOKEN, useValue: 10},
|
2016-06-09 13:23:29 -07:00
|
|
|
{provide: 'reference', useValue: common.NgIf},
|
2016-04-30 16:13:03 -07:00
|
|
|
{provide: 'complexToken', useValue: {a: 1, b: ['test', SOME_OPAQUE_TOKEN]}},
|
|
|
|
]
|
|
|
|
})
|
|
|
|
export class CompWithProviders {
|
2016-05-07 09:20:56 -06:00
|
|
|
constructor(@Inject('strToken') public ctxProp: string) {}
|
2016-04-30 16:13:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'cmp-reference',
|
|
|
|
template: `
|
2016-08-23 11:58:12 -07:00
|
|
|
<input #a [(ngModel)]="foo" required>{{a.value}}
|
2016-04-30 16:13:03 -07:00
|
|
|
<div *ngIf="true">{{a.value}}</div>
|
2016-08-19 12:51:01 -07:00
|
|
|
`
|
2016-04-30 16:13:03 -07:00
|
|
|
})
|
|
|
|
export class CompWithReferences {
|
2016-08-23 11:58:12 -07:00
|
|
|
foo: string;
|
2016-04-30 16:13:03 -07:00
|
|
|
}
|
2016-07-25 03:02:57 -07:00
|
|
|
|
2016-08-02 10:34:41 -07:00
|
|
|
@Component({selector: 'cmp-pipes', template: `<div *ngIf>{{test | somePipe}}</div>`})
|
|
|
|
export class CompUsingPipes {
|
|
|
|
}
|
|
|
|
|
2016-07-25 03:02:57 -07:00
|
|
|
@Component({
|
|
|
|
selector: 'cmp-custom-els',
|
|
|
|
template: `
|
|
|
|
<some-custom-element [someUnknownProp]="true"></some-custom-element>
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
export class CompUsingCustomElements {
|
|
|
|
}
|
|
|
|
|
2016-09-06 07:49:38 -07:00
|
|
|
@Component({
|
|
|
|
selector: 'cmp-event',
|
|
|
|
template: `
|
|
|
|
<div (click)="handleDomEventVoid($event)"></div>
|
|
|
|
<div (click)="handleDomEventPreventDefault($event)"></div>
|
|
|
|
<div (dirEvent)="handleDirEvent($event)"></div>
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
export class CompConsumingEvents {
|
|
|
|
handleDomEventVoid(e: any): void {}
|
|
|
|
handleDomEventPreventDefault(e: any): boolean { return false; }
|
|
|
|
handleDirEvent(e: any): void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Directive({
|
|
|
|
selector: '[dirEvent]',
|
|
|
|
})
|
|
|
|
export class DirPublishingEvents {
|
|
|
|
@Output('dirEvent')
|
|
|
|
dirEvent: Observable<string> = new EventEmitter();
|
|
|
|
}
|
|
|
|
|
2016-08-19 12:51:01 -07:00
|
|
|
@NgModule({schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: wrapInArray(CompUsingCustomElements)})
|
2016-07-25 03:02:57 -07:00
|
|
|
export class ModuleUsingCustomElements {
|
|
|
|
}
|