parent
							
								
									b137f09345
								
							
						
					
					
						commit
						9be222f448
					
				| @ -1,6 +1,5 @@ | |||||||
| // #docregion
 |  | ||||||
| import { Component, Injector } from '@angular/core'; | import { Component, Injector } from '@angular/core'; | ||||||
| import { createNgElementConstructor } from '../elements-dist'; | import { createCustomElement } from '@angular/elements'; | ||||||
| import { PopupService } from './popup.service'; | import { PopupService } from './popup.service'; | ||||||
| import { PopupComponent } from './popup.component'; | import { PopupComponent } from './popup.component'; | ||||||
| 
 | 
 | ||||||
| @ -15,7 +14,7 @@ import { PopupComponent } from './popup.component'; | |||||||
| export class AppComponent { | export class AppComponent { | ||||||
|   constructor(injector: Injector, public popup: PopupService) { |   constructor(injector: Injector, public popup: PopupService) { | ||||||
|     // Convert `PopupComponent` to a custom element.
 |     // Convert `PopupComponent` to a custom element.
 | ||||||
|     const PopupElement = createNgElementConstructor(PopupComponent, {injector}); |     const PopupElement = createCustomElement(PopupComponent, {injector}); | ||||||
|     // Register the custom element with the browser.
 |     // Register the custom element with the browser.
 | ||||||
|     customElements.define('popup-element', PopupElement); |     customElements.define('popup-element', PopupElement); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -1,4 +1,3 @@ | |||||||
| // #docregion
 |  | ||||||
| import { NgModule } from '@angular/core'; | import { NgModule } from '@angular/core'; | ||||||
| import { BrowserModule } from '@angular/platform-browser'; | import { BrowserModule } from '@angular/platform-browser'; | ||||||
| import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||||||
|  | |||||||
| @ -1,4 +1,3 @@ | |||||||
| // #docregion
 |  | ||||||
| import { Component, EventEmitter, Input, Output } from '@angular/core'; | import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||||||
| import { animate, state, style, transition, trigger } from '@angular/animations'; | import { animate, state, style, transition, trigger } from '@angular/animations'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,9 +1,8 @@ | |||||||
| 
 | 
 | ||||||
| // #docregion
 |  | ||||||
| import { ApplicationRef, ComponentFactoryResolver, Injectable, Injector } from '@angular/core'; | import { ApplicationRef, ComponentFactoryResolver, Injectable, Injector } from '@angular/core'; | ||||||
| 
 | import { NgElement, WithProperties } from '@angular/elements'; | ||||||
| import { PopupComponent } from './popup.component'; | import { PopupComponent } from './popup.component'; | ||||||
| import { NgElementConstructor } from '../elements-dist'; | 
 | ||||||
| 
 | 
 | ||||||
| @Injectable() | @Injectable() | ||||||
| export class PopupService { | export class PopupService { | ||||||
| @ -40,7 +39,7 @@ export class PopupService { | |||||||
|   // This uses the new custom-element method to add the popup to the DOM.
 |   // This uses the new custom-element method to add the popup to the DOM.
 | ||||||
|   showAsElement(message: string) { |   showAsElement(message: string) { | ||||||
|     // Create element
 |     // Create element
 | ||||||
|     const popupEl = document.createElement('popup-element'); |     const popupEl: NgElement & WithProperties<PopupComponent> = document.createElement('popup-element') as any; | ||||||
| 
 | 
 | ||||||
|     // Listen to the close event
 |     // Listen to the close event
 | ||||||
|     popupEl.addEventListener('closed', () => document.body.removeChild(popupEl)); |     popupEl.addEventListener('closed', () => document.body.removeChild(popupEl)); | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								aio/content/examples/elements/src/main.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								aio/content/examples/elements/src/main.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | import { enableProdMode } from '@angular/core'; | ||||||
|  | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||||||
|  | 
 | ||||||
|  | import { AppModule } from './app/app.module'; | ||||||
|  | import { environment } from './environments/environment'; | ||||||
|  | 
 | ||||||
|  | if (environment.production) { | ||||||
|  |   enableProdMode(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | platformBrowserDynamic().bootstrapModule(AppModule); | ||||||
| @ -22,6 +22,7 @@ | |||||||
|     "@angular/common": "^6.0.0", |     "@angular/common": "^6.0.0", | ||||||
|     "@angular/compiler": "^6.0.0", |     "@angular/compiler": "^6.0.0", | ||||||
|     "@angular/core": "^6.0.0", |     "@angular/core": "^6.0.0", | ||||||
|  |     "@angular/elements": "^6.0.0", | ||||||
|     "@angular/forms": "^6.0.0", |     "@angular/forms": "^6.0.0", | ||||||
|     "@angular/http": "^6.0.0", |     "@angular/http": "^6.0.0", | ||||||
|     "@angular/platform-browser": "^6.0.0", |     "@angular/platform-browser": "^6.0.0", | ||||||
|  | |||||||
| @ -140,6 +140,12 @@ | |||||||
|   dependencies: |   dependencies: | ||||||
|     tslib "^1.9.0" |     tslib "^1.9.0" | ||||||
| 
 | 
 | ||||||
|  | "@angular/elements@^6.0.0": | ||||||
|  |   version "6.0.9" | ||||||
|  |   resolved "https://registry.yarnpkg.com/@angular/elements/-/elements-6.0.9.tgz#6c238632631fa545f4893db8b48a4e89b2a277b2" | ||||||
|  |   dependencies: | ||||||
|  |     tslib "^1.9.0" | ||||||
|  | 
 | ||||||
| "@angular/forms@^6.0.0": | "@angular/forms@^6.0.0": | ||||||
|   version "6.0.0" |   version "6.0.0" | ||||||
|   resolved "https://registry.yarnpkg.com/@angular/forms/-/forms-6.0.0.tgz#436e2df39dc57db124da5a5c02bc63909fdf7046" |   resolved "https://registry.yarnpkg.com/@angular/forms/-/forms-6.0.0.tgz#436e2df39dc57db124da5a5c02bc63909fdf7046" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user