Question T14980
Visible to All Users

Custom Question Doesn't Rendered

created a year ago (modified a year ago)
TypeScript
Survey.ComponentCollection.Instance.add({             name: 'filecustom',             title: 'File Image',             questionJSON: {                 type: 'file',                 storeDataAsText: false,                 maxSize: 0,             },         });

I have registered custom component using Angular, and successfully appear on survey creator. But why when I try to render on Survey Page, my custom question is not rendered

JSON
{ "pages": [ { "name": "page1", "elements": [ { "type": "filecustom", "name": "question1", "title": "Image", "isRequired": true }, { "type": "file", "name": "question3", "title": "Image 2", "isRequired": true, "storeDataAsText": false, "maxSize": 0 }, { "type": "text", "name": "question2", "title": "Test", "isRequired": true } ] } ] }

Clipboard-File-1.png

Ohh I just wrong to choose package for add instance custom. After edit to ```
import { ComponentCollection } from 'survey-angular';

Code
ComponentCollection.Instance.add({           name: 'filecustom',           title: 'File Image',           questionJSON: {               type: 'file',               storeDataAsText: false,               maxSize: 0,           },       });

It successfully rendered

Answers approved by surveyjs Support

created a year ago

Hello Malvin,
Thank you for the update. I'm happy to hear that you resolved the issue. If you are using Angular v12.0.0 and newer, I would recommend that you consider a survey-angular-ui package: Add a Survey to an Angular Application.

Thanks

    Show previous comments (2)
    MP MP
    Malvin Patrick a year ago

      How about onDownloadFile ?

      JavaScript
      this.surveyModel.onDownloadFile.add((survey, options) => { console.log('options', options); }):

      options there have no question object
      Clipboard-File-1.png

        Hello Malvin,
        A question object is available within the survey.onDownloadFile function arguments. You can obtain a question instance using the options.question, and get its parent element via options.question.parent. Consider this demo: View CodeSandbox.

        Please let me know if this helps.

        MP MP
        Malvin Patrick a year ago

          But I use

          Code
          "survey-angular": "^1.8.55",

          And I got undefined, take a look on my screen shot. There is no question object there

          Other Answers

          created a year ago

          Ahaaa, after I updates into "survey-angular": "1.9.112",, then there's a question object. Thanks Jane

            Comments (1)

              You're very welcome, Malvin. Please feel free contact us if you have any further questions.