mardi 15 août 2017

Back to the prevois page in angular2 when all the changing in first page are kept.

In Angular2 I'm working on a web application. On one of my pages there is checkbox that if user clicks on, another check box is appeard. Then the NEXT button becomes active and user goes to next page. On the next page I have BACK button that is redirected to previous page. But the problem is if you click on BACK button you are gonna redirected to the page when you haven't had checked the checkbox. So the user should do it agian. My question is how I should redirect to back to the same situation that I left the page?

here is my code:

  <button href="" (click)="back()"> Back </button>

component.ts of page two:

export class PageTwoComponent implements OnInit {
  @Output() backedToPageOne = new EventEmitter<void>();

 back() {
     this.backedToPageOne.emit();
  }

component.ts of first page:

export class FirstPageComponent implements OnInit {

 backedToPageOne() {
    this.openShareBlock();
  }

  openShareBlock() {
    this.showShareBlock = true;
    this.scrollToNextBlock(100);
  }

html of first page. when you check the first checkbox this(second checkbox) gonna be shown:

 <div class="row main__permissions" *ngIf="showShareBlock>
    <div class="col-xs-12">
        <div class="panel-body">
            <div class="field__checkbox">
                <label>
                    <input type="radio" name="share" value="yes" [(ngModel)]="currentConsent.share" />
                    Yes
                </label>
            </div>
            <div class="field__checkbox">
                <label>
                    <input type="radio" name="share" value="no" [(ngModel)]="currentConsent.share" />
                    No
                </label>
            </div>
        </div>
    </div>
</div>

But on the second page if I click on back, I will be ended to the first page that I need to check the box again. Is there any suggestion for this?




Aucun commentaire:

Enregistrer un commentaire