2016-06-22 14:06:23 -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-07-07 10:05:55 -07:00
|
|
|
import {ANALYZE_FOR_PRECOMPILE, Component, ComponentFactoryResolver, Inject, OpaqueToken} from '@angular/core';
|
|
|
|
|
|
2016-06-30 13:07:17 -07:00
|
|
|
import {BasicComp} from './basic';
|
2016-06-22 14:06:23 -07:00
|
|
|
|
2016-06-30 13:07:17 -07:00
|
|
|
@Component({selector: 'cmp-precompile', template: '', precompile: [BasicComp]})
|
2016-06-22 14:06:23 -07:00
|
|
|
export class CompWithPrecompile {
|
|
|
|
|
constructor(public cfr: ComponentFactoryResolver) {}
|
|
|
|
|
}
|
2016-07-07 10:05:55 -07:00
|
|
|
|
|
|
|
|
export const SOME_TOKEN = new OpaqueToken('someToken');
|
|
|
|
|
|
|
|
|
|
export function provideValueWithPrecompile(value: any) {
|
|
|
|
|
return [
|
|
|
|
|
{provide: SOME_TOKEN, useValue: value},
|
|
|
|
|
{provide: ANALYZE_FOR_PRECOMPILE, useValue: value, multi: true},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'comp-precompile-provider',
|
|
|
|
|
template: '',
|
|
|
|
|
providers: [provideValueWithPrecompile([{a: 'b', component: BasicComp}])]
|
|
|
|
|
})
|
|
|
|
|
export class CompWithAnalyzePrecompileProvider {
|
|
|
|
|
constructor(public cfr: ComponentFactoryResolver, @Inject(SOME_TOKEN) public providedValue: any) {
|
|
|
|
|
}
|
|
|
|
|
}
|