2016-06-28 12:54:42 -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
|
|
|
|
*/
|
|
|
|
|
2017-03-13 14:32:07 -04:00
|
|
|
import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, Directive, Injectable, InjectionToken, Input, NgModule, Pipe} from '@angular/core';
|
2016-06-28 12:54:42 -04:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class SomeService {
|
|
|
|
public prop = 'someValue';
|
|
|
|
}
|
|
|
|
|
|
|
|
@Injectable()
|
2016-07-18 06:50:31 -04:00
|
|
|
export class ServiceUsingLibModule {
|
2016-06-28 12:54:42 -04:00
|
|
|
}
|
|
|
|
|
2016-07-07 14:57:11 -04:00
|
|
|
@Directive({selector: '[someDir]', host: {'[title]': 'someDir'}})
|
2016-07-18 06:50:31 -04:00
|
|
|
export class SomeDirectiveInRootModule {
|
2016-07-07 14:57:11 -04:00
|
|
|
@Input()
|
|
|
|
someDir: string;
|
|
|
|
}
|
|
|
|
|
2016-07-18 06:50:31 -04:00
|
|
|
@Directive({selector: '[someDir]', host: {'[title]': 'someDir'}})
|
|
|
|
export class SomeDirectiveInLibModule {
|
|
|
|
@Input()
|
|
|
|
someDir: string;
|
2016-06-28 12:54:42 -04:00
|
|
|
}
|
|
|
|
|
2016-07-18 06:50:31 -04:00
|
|
|
@Pipe({name: 'somePipe'})
|
|
|
|
export class SomePipeInRootModule {
|
|
|
|
transform(value: string): any { return `transformed ${value}`; }
|
2016-06-28 12:54:42 -04:00
|
|
|
}
|
|
|
|
|
2016-07-18 06:50:31 -04:00
|
|
|
@Pipe({name: 'somePipe'})
|
|
|
|
export class SomePipeInLibModule {
|
|
|
|
transform(value: string): any { return `transformed ${value}`; }
|
2016-06-28 12:54:42 -04:00
|
|
|
}
|
|
|
|
|
2016-07-18 06:50:31 -04:00
|
|
|
@Component({selector: 'comp', template: `<div [someDir]="'someValue' | somePipe"></div>`})
|
|
|
|
export class CompUsingRootModuleDirectiveAndPipe {
|
2016-06-28 12:54:42 -04:00
|
|
|
}
|
|
|
|
|
2016-07-18 06:50:31 -04:00
|
|
|
@Component({selector: 'comp', template: `<div [someDir]="'someValue' | somePipe"></div>`})
|
|
|
|
export class CompUsingLibModuleDirectiveAndPipe {
|
2016-06-28 12:54:42 -04:00
|
|
|
}
|
2016-07-07 13:05:55 -04:00
|
|
|
|
2017-01-03 19:54:46 -05:00
|
|
|
export const SOME_TOKEN = new InjectionToken('someToken');
|
2016-07-07 13:05:55 -04:00
|
|
|
|
2016-07-25 03:36:30 -04:00
|
|
|
export function provideValueWithEntryComponents(value: any) {
|
2016-07-07 13:05:55 -04:00
|
|
|
return [
|
|
|
|
{provide: SOME_TOKEN, useValue: value},
|
2016-07-25 03:36:30 -04:00
|
|
|
{provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: value, multi: true},
|
2016-07-07 13:05:55 -04:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-07-18 06:50:31 -04:00
|
|
|
@NgModule({
|
|
|
|
declarations: [SomeDirectiveInLibModule, SomePipeInLibModule, CompUsingLibModuleDirectiveAndPipe],
|
2016-07-25 04:39:50 -04:00
|
|
|
exports: [CompUsingLibModuleDirectiveAndPipe],
|
2016-07-25 03:36:30 -04:00
|
|
|
entryComponents: [CompUsingLibModuleDirectiveAndPipe],
|
2016-07-18 06:50:31 -04:00
|
|
|
})
|
|
|
|
export class SomeLibModule {
|
2016-11-29 15:02:50 -05:00
|
|
|
static withProviders() {
|
|
|
|
return {
|
|
|
|
ngModule: SomeLibModule,
|
|
|
|
providers: [
|
|
|
|
ServiceUsingLibModule, provideValueWithEntryComponents(
|
|
|
|
[{a: 'b', component: CompUsingLibModuleDirectiveAndPipe}])
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
2016-07-25 04:39:50 -04:00
|
|
|
}
|