| 
									
										
										
										
											2015-12-10 09:40:54 -08:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  | import { Injectable } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-12-10 09:40:54 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Async modal dialog service | 
					
						
							|  |  |  |  * DialogService makes this app easier to test by faking this service. | 
					
						
							|  |  |  |  * TODO: better modal implemenation that doesn't use window.confirm | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @Injectable() | 
					
						
							|  |  |  | export class DialogService { | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Ask user to confirm an action. `message` explains the action and choices. | 
					
						
							|  |  |  |    * Returns promise resolving to `true`=confirm or `false`=cancel | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2016-05-02 16:53:25 -07:00
										 |  |  |   confirm(message?: string) { | 
					
						
							| 
									
										
										
										
											2015-12-10 09:40:54 -08:00
										 |  |  |     return new Promise<boolean>((resolve, reject) => | 
					
						
							|  |  |  |       resolve(window.confirm(message || 'Is it OK?'))); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |