Survey JS. Has anyone worked with it?

Has anyone tried using SurveyJs in their meteor application. I’m using TS and I have successfully imported the library into meteor. However when I run it I get the following error:

survey_jquery_1.Survey.Model is not a constructor

Well. This was my own stupidity. I imported the Javascript version of the library instead of the angular one. So the correct import would be

meteor npm install survey-angular

BTW. It works really well…

2 Likes

Can anyone show me how you did your imports? I’m using Blaze and survey-jquery and getting the Survey.Model is not a constructor error.

import {Template} from "meteor/templating"
import $ from 'jquery'
import { Survey, Model } from 'survey-jquery'
import './survey-form.html'

Template.surveyForm.onRendered(function() {
    const template = Template.instance()
    const surveyData = {
        "pages": [
            {
                "name": "page1",
                "elements": [
                    { "type": "text", "name": "question1" }
                ]
            }
        ]
    }

    let surveyInstance = new Survey.Model(surveyData)

    template.$("#surveyFormContainer").Survey({
        model: surveyInstance,
        onComplete: function todo () {}
    })
})

P.S. I have survey-creator working just fine, saving me a ton of work!

Got the solution:

import * as Survey from 'survey-jquery'
1 Like

I guess it depends if you are using JS or Angular. I was using Angular so for me it was

import * as Survey from "survey-angular";