I am working in angular 2. I have two components one is for my form and another is for my dialog box & when I have click on button present in form I will get a dialog box which hold the check boxes and return the value of checked check boxes in a variable. Now my question is that I want to access variable of dialog component in form component.
-
motor-cycle-package.component.ts
moterCyclePackages = [ { "name": "P1", "value":"P1", "price": "20","state": false}, { "name": "P2", "value":"P2", "price": "30", "state": false}, { "name": "P3", "value":"P3", "price": "40", "state": false} ]; constructor(public dialogRef: MdDialogRef) { }
-
form.service.ts
constructor(private http: Http, private dialog: MdDialog) { } public motorCyclePackage(): Observable{ let motorCycleRef: MdDialogRef; motorCycleRef = this.dialog.open(MotorCyclePackageComponent); console.log(motorCycleRef); return motorCycleRef.afterClosed(); }
-
user-form.Component.ts
constructor(fb: FormBuilder, private formservice:formService){} public motorCyclePackage() { this.formservice .motorCyclePackage() .subscribe(res => this.result = res); }
via Lakhvir Singh
No comments:
Post a Comment