angular2 components - Angular change detection issue -


i new angular , have gone through of change detection techniques unfortunately not getting right output. have 2 form views. show first view(user view) , on click of button show next view( password change view ). views nothing sections in form.

  1. user view

this has user id field , 1 button continue.

  1. password change view

this has 3 fields ( user id, field1, field2)

when click on continue button of first view should show me second view. using same variable "scalarsection" show both views.

the problem first view 'userview' loads fine. second view 'passwordresetview' not load , continues show me first view. if see component variable 'scalarsection' correctly seen new metadata values belonging 'passwordresetview'.

below have component below code. don't have except bare essentials.

@component({ selector: 'adv-vss-simplescalar-page', changedetection: changedetectionstrategy.onpush, 

template:

    <div>              <div [class]="sectioncanvas">                 <div [class]="section">                                         <adv-scalar-section-with-actions                         [viewversion]="viewversion"                         [displaysectiontitle]="false"                         [basicscalarsection]="scalarsection">                     </adv-scalar-section-with-actions>                                              </div>             </div>         </div>     </div>  ,  providers: [pageeventservice, pagestate]  }) 

//here class component

       export class simplescalarpage extends commonpage.commonpage             implements oninit, ondestroy, onchanges {               scalarsection: ibasicscalarsection;              constructor(                 pgevtsvc: pageeventservice,                 pgstate: pagestate,                 vmevtsvc: viewmgreventservice,                 dfs: datafetchservice,                 log: loggerservice,                 cdr: changedetectorref,                 cfr: componentfactoryresolver             ) {                 super(pgevtsvc, pgstate, vmevtsvc, dfs, log, cdr, cfr);             }    datafetchcompleted(response: any) {     super.datafetchcompleted(response);      if (!!this.getpagemetadata()) {         let currview = this.pgstate.metadata.getcurrentview();         this.currentviewname = currview.getname();         console.log("this.currentviewname " + this.currentviewname)          this.setupscalarviewmodel(this.getpagemetadata(), this.currentviewname);      }      //this setup input fields intro text     setupscalarviewmodel(pagemetadata: ipagemetacomp, currentviewname: string) {         if (!!pagemetadata) {             let currview = pagemetadata.getcurrentview();             let scalar_container = pagemetadata.getchildcontainer(currentviewname);              let pagesection = 'simplescalarsection';              this.scalarsection =                 new basicscalarsection(scalar_container.getchildcontainer(pagesection),                     'scalar_sect_construct_section_card_scalar_nested',                     'datasource');              //get title             this.pagetitle = scalar_container.getpropval('title');              // set required text on top right             // todo: value page level template, , decide if show required text or not             this.pagetoprighttext = '* required text';         }     }  } 

// if below code work don't want hard code value generic template form.

 <div [class]="sectioncanvas">        <div [class]="section">             <div *ngif="currentviewname === 'userview'">                  <adv-scalar-section-with-actions                             [viewversion]="viewversion"                             [displaysectiontitle]="false"                             [basicscalarsection]="scalarsection">                    </adv-scalar-section-with-actions>               </div>               <div *ngif="currentviewname === 'passwordanswerverifyview'">                    <adv-scalar-section-with-actions                         [viewversion]="viewversion"                         [displaysectiontitle]="false"                         [basicscalarsection]="scalarsection">                     </adv-scalar-section-with-actions>                </div>                   </div>           </div> 


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 -