Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Model
- export interface IPoducts{
- recordname: string;
- comments: [{
- comment: string
- }]
- }
- constructor(public dialog: MdDialog, private productService: ProductService){}
- prod: IProducts[]=[]
- ngOnInit(): void{ this.productService.getProcessnotes().subscribe(producsts=>this.products=products,error=>this.errorMessage=<any>error);
- //opening dialgue
- openDialog(prod:any): void {
- let dialogRef = this.dialog.open(prodDialog, {
- width: '400px',
- height: '500px;',
- data: this.prod <------------------passing the object array
- });
- }}
- export class ProdDialog implements OnInit{
- public pnote: IProducts[];
- constructor(
- public dialogRef: MdDialogRef<DialogOverviewExampleDialog>,
- @Inject(MD_DIALOG_DATA) public data: {pnote:this.prod }) { }
- public pnote: products;
- onNoClick(): void {
- this.dialogRef.close();
- }
- public ngOnInit():void{
- this.pnote=this.data.prod;
- }
- In main template button triggers the dialog box by passing a pnote from *ngFor="let pnote of products"
- <button md-raised-button (click)="openDialog(pnote)">Open Dialog</button>
- <div>
- <h2 md-dialog-title>MY DIALOG</h2>
- <hr>
- <md-dialog-content>
- <div*ngFor=prod in products>
- {{prod.recorname}}
- </div>
- <br>
- <br>
- <strong>{{data}}</strong>
- </md-dialog-content>
- <hr>
- <md-dialog-actions>
- <button md-raised-button (click)="onCloseConfirm()">CONFIRM</button>
- <button md-raised-button (click)="onCloseCancel()">CANCEL</button>
- </md-dialog-actions>
- </div>
Add Comment
Please, Sign In to add comment