19 lines
		
	
	
		
			579 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
		
		
			
		
	
	
			19 lines
		
	
	
		
			579 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| 
								 | 
							
								// #docregion
							 | 
						||
| 
								 | 
							
								import {Injectable} from 'angular2/core';
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * 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
							 | 
						||
| 
								 | 
							
								   */
							 | 
						||
| 
								 | 
							
								  confirm(message?:string) {
							 | 
						||
| 
								 | 
							
								    return new Promise<boolean>((resolve, reject) =>
							 | 
						||
| 
								 | 
							
								      resolve(window.confirm(message || 'Is it OK?')));
							 | 
						||
| 
								 | 
							
								  };
							 | 
						||
| 
								 | 
							
								}
							 |