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