第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何在 Angular 中使用 mat-card 的材質(zhì)分頁(yè)?

如何在 Angular 中使用 mat-card 的材質(zhì)分頁(yè)?

慕妹3146593 2023-12-19 16:09:29
<div class="main-div"> <mat-card class="main" *ngFor="let topics of topics">  <mat-card-content>   <div class="row">     <div class="column left">    <img class="responsive" src="https://newworldhub.com/api/assets/{{topics.profilePicture}}">    <p>{{topics.name}}</p>    <p>Posted {{Math.round(topics.dateDiff/1440)}}</p>  </div>  <div class="column middle text-in-tile">    <h1 routerLink="{{topics.topicId}}"        (click)="this.forumService.setPostToken(topics.topicId)">{{topics.topicSubject}}</h1>    <p class="content">{{topics.topicContent}}</p>  </div></div></mat-card-content></mat-card><mat-paginator [length]="100"             [pageSize]="1"             [pageSizeOptions]="[1, 10, 25, 100]"></mat-paginator></div>html^^export class TopicsComponent implements OnInit {form: FormGroup;topics: Topics[];Math: Math = Math;constructor(            public forumService: ForumService,             public dataService: DataserviceService,             public metaService: Meta,             public titleService: Title) {} ngOnInit() {   this.forumService.getTopics().subscribe((topics: Topics[]) => {   this.topics = topics;   console.log(this.topics);   });   this.titleService.setTitle("Forum | New World Hub");   this.metaService.updateTag({ name: 'description', content: 'Guides for every aspect of Amazons game New World'}); }}我很好奇如何通過(guò)設(shè)置論壇主題的方式來(lái)實(shí)現(xiàn)分頁(yè)。我在這里找到了幾種不同的方法,但它們都不適合我當(dāng)前存儲(chǔ)數(shù)據(jù)的方式。
查看完整描述

1 回答

?
ITMISS

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊

您的 html 代碼很好,然后在組件中聲明 matPaginator 并訂閱可觀察的頁(yè)面:


import { MatPaginator } from '@angular/material/paginator';


export class TopicsComponent implements OnInit, AfterViewInit {


form: FormGroup;


topics: Topics[];


Math: Math = Math;


@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;


constructor(

            public forumService: ForumService, 

            public dataService: DataserviceService, 

            public metaService: Meta, 

            public titleService: Title) {

}


 ngOnInit() {

//take just one value from the getTopics() for the first page

   this.forumService.getTopics().pipe(take(1)).subscribe((topics: Topics[]) => {

   this.topics = topics;

   console.log(this.topics);

   });


   this.titleService.setTitle("Forum | New World Hub");

   this.metaService.updateTag({ name: 'description', content: 'Guides for every aspect of Amazons game New World'});

 }


//the viewChild decorator return only in the ngAfterViewInit method

  ngAfterViewInit(){

    this.paginator.page.pipe(

     switchMap(() => {

       // do whatever with the current page size and page index

       const pageIndex = this.paginator.pageIndex

       const pageSize = this.paginator.pageSize


       // run getTopics() to your service with the current page index(make sure your functions supports it)

       return this.getTopics({page: pageIndex})

     })

    ).subscribe((topics) => {

      this.topics = topics

    })

  }


}


查看完整回答
反對(duì) 回復(fù) 2023-12-19
  • 1 回答
  • 0 關(guān)注
  • 146 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)