Thanks for the great example repo! I'm still learning the ropes of surveyJS and Ionic, so this might be a silly question and hopefully you don't mind:
I'm trying to integrate the navcontroller into my survey component:
import {Component, Input} from '@angular/core';
import * as Survey from 'survey-angular';
import {NavController} from "ionic-angular";
/**
* Generated class for the SurveyComponent component.
*
* See https://angular.io/api/core/Component for more info on Angular
* Components.
*/
@Component({
selector: 'survey',
templateUrl: 'survey.html'
})
export class SurveyComponent {
surveyJSON: any;
@Input()
set json(surveyJSON) {
Survey.Survey.cssType = "bootstrap";
Survey.defaultBootstrapCss.navigationButton = "btn btn-green";
this.surveyJSON = surveyJSON;
let surveyModel = new Survey.ReactSurveyModel(surveyJSON);
// Progress Bar.
surveyModel.showProgressBar = 'bottom';
// surveyModel.onComplete.add(this.sendDataToServer);
surveyModel.onComplete.add(this.doPop);
Survey.SurveyNG.render('surveyElement', {model: surveyModel});
}
constructor(public navCtrl: NavController) {
console.log('survey component loaded');
console.log(this.navCtrl);
}
doPop() {
console.log(this.navCtrl);
this.navCtrl.pop();
}
}
When the page gets rendered I see the navcontroller in the console as expected from the constructor. However, once the survey is complete this.navCtrl is undefined inside doPop():
TypeError: Cannot read property 'pop' of undefined
at Array.webpackJsonp.287.SurveyComponent.doPop (http://localhost:8100/build/main.js:1053:22)
at Event.fire (http://localhost:8100/build/vendor.js:122947:47)
at ReactSurveyModel.SurveyModel.doComplete (http://localhost:8100/build/vendor.js:126150:25)
at ReactSurveyModel.SurveyModel.completeLastPage (http://localhost:8100/build/vendor.js:126102:14)
at SurveyNavigation.handleCompleteClick (http://localhost:8100/build/vendor.js:131314:21)
at HTMLInputElement.eventProxy (http://localhost:8100/build/vendor.js:131937:39)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15040)
at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4238:33)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:14961)
at r.runTask (http://localhost:8100/build/polyfills.js:3:10214)
It seems the issue is that the this context gets lost once the doPop() is added to onComplete. Any suggestions on how to integrate the navcontroller into my surveyModel.onComplete call?
Thanks for the great example repo! I'm still learning the ropes of surveyJS and Ionic, so this might be a silly question and hopefully you don't mind:
I'm trying to integrate the navcontroller into my survey component:
When the page gets rendered I see the navcontroller in the console as expected from the constructor. However, once the survey is complete
this.navCtrl
is undefined insidedoPop()
:It seems the issue is that the
this
context gets lost once thedoPop()
is added toonComplete
. Any suggestions on how to integrate the navcontroller into mysurveyModel.onComplete
call?Thanks!