angular - ngIf with viewchild -


i'm new @ angular2 , not professional. have parent-child component want when user click on button selector of child component show something. should condition , used child component. here codes: parent html:

<div *ngif="page2">       <add-property-page2></add-property-page2>     </div>      <div class="text-center col-sm-12">       <button [disabled]="!propertyform.form.valid"               (click)="onsubmit($event,value,amlak)"               type="submit" class="btn btn-success">continue       </button>     </div> 

and parent component:

import {component, oninit, viewchild, viewencapsulation, input } '@angular/core'; import {amlak} '../models/amlak'; import {addpropertypage2component} './add-paroperty-page2.component'; @component({  selector: 'add-property',  styleurls: ['./selection.css'],  templateurl: './add-property.html',  providers: [dataservice, amlak],  }) export class addpropertycomponent  { private page2: boolean; @viewchild(addpropertypage2component) private addpropertypage2: addpropertypage2component; constructor(private amlak: amlak, private dataservice: dataservice ) { this.userlogined = authenticationservice.check();  } onsubmit($event:any,value,amlak) { $event.preventdefault(); if (this.page2) {   this.amlak.emkanat = this.addpropertypage2.emkan.filter(e => e.checked ==   true);  } } 

now question easiest way show selector of child in parent when user click. because error : cannot read property 'emkan' of undefined. know it's because of *ngif don't know should do. should can use viewchild method in code. thank in easy way.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -