Guest User

Untitled

a guest
Dec 14th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. Model
  2. export interface IPoducts{
  3. recordname: string;
  4. comments: [{
  5. comment: string
  6. }]
  7. }
  8.  
  9. constructor(public dialog: MdDialog, private productService: ProductService){}
  10. prod: IProducts[]=[]
  11. ngOnInit(): void{ this.productService.getProcessnotes().subscribe(producsts=>this.products=products,error=>this.errorMessage=<any>error);
  12.  
  13. //opening dialgue
  14. openDialog(prod:any): void {
  15. let dialogRef = this.dialog.open(prodDialog, {
  16. width: '400px',
  17. height: '500px;',
  18. data: this.prod <------------------passing the object array
  19. });
  20. }}
  21.  
  22. export class ProdDialog implements OnInit{
  23. public pnote: IProducts[];
  24. constructor(
  25. public dialogRef: MdDialogRef<DialogOverviewExampleDialog>,
  26. @Inject(MD_DIALOG_DATA) public data: {pnote:this.prod }) { }
  27. public pnote: products;
  28. onNoClick(): void {
  29. this.dialogRef.close();
  30. }
  31. public ngOnInit():void{
  32. this.pnote=this.data.prod;
  33.  
  34. }
  35.  
  36. In main template button triggers the dialog box by passing a pnote from *ngFor="let pnote of products"
  37.  
  38. <button md-raised-button (click)="openDialog(pnote)">Open Dialog</button>
  39.  
  40. <div>
  41. <h2 md-dialog-title>MY DIALOG</h2>
  42. <hr>
  43. <md-dialog-content>
  44. <div*ngFor=prod in products>
  45. {{prod.recorname}}
  46. </div>
  47. <br>
  48. <br>
  49. <strong>{{data}}</strong>
  50. </md-dialog-content>
  51. <hr>
  52. <md-dialog-actions>
  53. <button md-raised-button (click)="onCloseConfirm()">CONFIRM</button>&nbsp;
  54. <button md-raised-button (click)="onCloseCancel()">CANCEL</button>
  55. </md-dialog-actions>
  56. </div>
Add Comment
Please, Sign In to add comment