question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 2 examples - result and settings

See original GitHub issue

Are you requesting a feature, reporting a bug or ask a question?

Question: I worked with your Angular examples and get the survey running. However how to reach the result data? Sorry, my limited knowledge of Angular didn’t help.

What is the current behavior?

Can’t get the result into a custom function (leading to an Angular service).

What is the expected behavior?

To obtain the results in a variable, and to be able to insert settings.

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

export class SurveyComponent implements OnInit, OnDestroy  {
    private surveyJSON: any;
        
    constructor(){}
    
    ngOnInit() {
        let params: any = this.activatedRoute.snapshot.params;
        this.surveyJSON = this._drpService.getSuveyJson(+params.id);
        const survey = new Survey.ReactSurveyModel(this.surveyJSON);
        Survey.SurveyNG.render('surveyElements', { model: this.survey });
    }

Specify your

  • browser:
  • browser version:
  • surveyjs platform (angular or react or jquery or knockout or vue):
  • surveyjs version: 0.12.17

THANK YOU! Best, Roeneman

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rroenemancommented, Jun 30, 2017

Thank you, got it sorted. This is my solution:

...
export class ...
  private mysurvey:any;
  private surveyJSON:any;
    ngOnInit() {
        this.surveyJSON = .... get the surveyJSON out of a service or just copy it here ....
        this.mysurvey = new Survey.ReactSurveyModel(this.surveyJSON);
        Survey.SurveyNG.render('surveyElements', { model: this.mysurvey });

HERE STARTS THE DIFFERENCE, CALL COMPONENT FUNCTION FROM NESTED FUNCTION WITH THE ARROW 
        this.mysurvey.onComplete.add(() => { 
           this.surveyResult(); 
        });
    }

   surveyResult(){
      //ACCESS DATA LIKE THIS
      console.log(this.mysurvey.data);
  }
}

Thanks for your help, so indeed it was not surveyJs but actually I believe a typescript issue. Best, Roeneman

0reactions
dmitrykurmanovcommented, Jun 29, 2017

@rroeneman you could create an example in plunker based on one of our examples (https://plnkr.co/edit/?p=preview) and we will try to help you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sharing data between child and parent directives ... - Angular
A common pattern in Angular is sharing data between a parent component and one or more child components. Implement this pattern with the...
Read more >
Cheat Sheet - Angular
Declares an output property that fires events that you can subscribe to with an event binding (example: <my-cmp (myEvent)="doSomething()"> ).
Read more >
Getting started with Angular
Prerequisiteslink · Take a tour of the example applicationlink · Create the sample projectlink · Create the product listlink · Pass data to...
Read more >
Attribute directives - Angular
Change the appearance or behavior of DOM elements and Angular components with attribute directives. See the live example / download example for a...
Read more >
Transforming Data Using Pipes - Angular
Chain pipes so that the output of one pipe becomes the input to the next. In the following example, chained pipes first apply...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found