使用$ state.go导航到页面的问题

时间:2019-04-17 09:41:58

标签: angularjs

我对angularJ相当陌生,并且对导航存在疑问。系统列出检查行。

类型X的检查1 Y型检查2

当我单击“检查2”时,将转到“数据捕获”的第1页。如果我单击返回列表并单击“检查1”,这有时会将我定向到数据捕获的第3页,有时只是将其转到第1页,理想情况下,如果希望系统始终将我定向到第3页。 / p>

我想知道你们中是否有人曾经遇到过这个问题。

当我调试代码时,它确实进入$ init方法的Page 3控制器,然后无缘无故跳到Page 1的控制器。

InspectionList控制器

this.captureCiiService.getPresentAtTheInspection(inspectionId)
                    .subscribe(
                        response => {
                            check[10] = response.message.presentAtTheInspection.some(person => person.role = 'O' && person.personFullName);
                            check[11] = response.message.presentAtTheInspection.some(person => person.role = 'E' && person.personFullName);

                            if (!check.some(item => !item)) {
                                this.captureNavigationStore.set({ ...this.captureNavigationStore.get(), currentIndex: 2 });
                                console.log(`State Name is ${  this.$state.current.name}`);

                                this.$state.go('capture.capture-bov.page3-inspection', { brn: this.captureState.inspectionHistory[0].riskCaseDetails.riskAnalysisCase.brn });
                            } else {
                                this.captureNavigationStore.set({ ...this.captureNavigationStore.get(), currentIndex: 0 });
                                this.$state.go('capture.capture-bov.page1-inspection', { brn: this.captureState.inspectionHistory[0].riskCaseDetails.riskAnalysisCase.brn });
                            }
                        },
                        failure => {
                            this.notificationService.error('Issue with navigating');
                        }
                    );
            },
            error => {
                this.notificationService.error('Issue retrieving inspection details');
            });

'''

下面的Page3控制器:

import { combineLatest } from 'rxjs/observable/combineLatest';



$onInit() {
    this.riskCaseAuthenticationSubscription = combineLatest(this.riskCaseStore.$store, this.authenticationStore.$store)
        .subscribe(data => {
            this.riskCaseState = data[0];
            this.riskCase = { ...this.riskCaseState.assignedEntities[this.$stateParams.brn] };
            this.authenticationState = data[1];
            this.userIsAssignedToInspection = this.riskCase.currentAssignee === this.authenticationState.username;
            this.captureCiiService.setAnimalResultsPaging(this.riskCase.riskAnalysisCase.inspectionId);
            this.getLocationsForBusiness();

        });

    this.captureFilterSubscription = combineLatest(this.captureStore.$store)
        .subscribe(data => {
            this.captureState = data[0];  <--***gets here***
            this.readonlyMode = this.captureState.readonlyCaptureMode;

        });


}

它会转到突出显示的行,然后无缘无故跳到Page 1控制器。有任何想法吗?谢谢

0 个答案:

没有答案