首页 > 解决方案 > ngx-fullpage - 如何访问 OnLeave 中的角度变量?

问题描述

我有这个...

<div mnFullpage [mnFullpageOnLeave]="onLeave">
 <div class="section welcome-section fp-section fp-table" *ngFor="let p of this.content.pages">
<div class="fp-tableCell">
  <div class="page">
    <div class="contentLayer">
      Content goes here
    </div>
  </div>
</div>

import { Component } from '@angular/core';
import { MnFullpageService } from 'ngx-fullpage';

@Component({
 selector: 'app-main-page',
 templateUrl: './mainPage.component.html',
 styleUrls: ['./mainPage.component.scss']
})
export class MainPageComponent {
readonly content = Content
pageIndex: number = 0;
constructor(public fullpageService: MnFullpageService) {

}
onLeave(index: number, nextIndex: object, direction: string): void {
   this.pageIndex = nextIndex.index;
}
}

问题是……当我在 onLeave 中设置变量 pageIndex 时……这没有反映出来。有什么建议吗?

标签: angularfullpage.js

解决方案


推荐阅读