简体   繁体   English

Angular中的上一个和下一个按钮

[英]Prev and Next buttons in Angular

I want to go from page 1 to page 4, in Angular 4, with a prev and next button. 我想从Angular 4的第1页转到第4页,使用上一个和下一个按钮。 Each page, from 1 to 4, is a individual component. 每个页面(从1到4)都是一个单独的组件。

My buttons component is on the bottom on each page. 我的按钮组件在每个页面的底部。

<div class="d-flex flex-row">
 <div class="trade-75"><button type="button" class="btn trade-back">

 </button></div>
 <div class="trade-10"><button type="button" class="btn trade-next">

 </button></div>
</div>

I was thinking to put in an array all components and to loop thought this array, but I don't know how to do this in Angular 4 :). 我当时想将所有组件放入一个数组中,并以该数组作为循环对象,但是我不知道如何在Angular 4中做到这一点:)。 Is there anyone who can help me? 有谁可以帮助我吗?

I would probably do something simple like this 我可能会做这样简单的事情

<div class="page">
    <my-first-page *ngIf="currentPage == 0"></my-first-page>
    <my-second-page *ngIf="currentPage == 1"></my-second-page>
    <my-third-page *ngIf="currentPage == 2"></my-third-page>
    <my-fourth-page *ngIf="currentPage == 3"></my-fourth-page>
</div>
<div class="d-flex flex-row">
    <div class="trade-75">
        <button type="button" class="btn trade-back" (click)="changePage(-1)"></button>
    </div>
     <div class="trade-10">
        <button type="button" class="btn trade-next" (click)="changePage(1)"></button>
    </div>
</div>

and in a component 并在组件中

export class WizardComponent {
    public currentPage = 0;
    public changePage(delta: number): void {
        // some checks
        currentPage += delta;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 增量在上一个,下一个按钮Angular 4中不起作用 - Incrementing doesn't work in prev, next buttons Angular 4 基于angular2中的第一个div和最后一个div显示或隐藏上一个和下一个按钮 - Show or Hide Prev and next buttons based on first div and last div in angular2 Angular Primeng carousel - 自定义 Prev 和 Next 按钮 - Angular Primeng carousel - Custom Prev and Next button 下一个和上一个不适用于angular2-Materialize轮播 - Next and prev not working with angular2-Materialize carousel 剑道滚动视图(角度)下一个/上一个方法使用 - Kendo scrollview(angular) next/prev methods use 如何在 Angular 中获取上一个/下一个数组字符串 - How to get the prev/next array string in Angular 如何处理 Angular FullCalendar 中的 next、prev 和 view 更改的操作 - How to handle actions on next, prev and view changes in Angular FullCalendar Angular 应用程序中的 Swiper.js 拇指已同步上一个和下一个 - Swiper.js thumbs in Angular app synced prev & next 如何使用 Angular 7 cli 的全日历捕捉下一个、上一个、今天的事件 - how to catch next, prev, today event with fullcalendar for Angular 7 cli 单击角度2中的上一个和下一个按钮时,下拉值更改 - Drop down value change on clicking prev and next button in angular 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM