### File

`src/question/checkbox.model.ts`

### Extends

`Question`

### Index

###### Properties
Public defaultOption
###### Methods
Public fromJson

### Constructor

`constructor(name: string, description: string, dependencies: Dependency[], answer: Answer | boolean, validations: Validation[], disabled: boolean, defaultOption: boolean)`
Defined in src/question/checkbox.model.ts:21
Parameters :
Name | Type | Optional | Description
name | `string` |  |
description | `string` |  |
dependencies | `Dependency[]` |  |
answer | `Answer | boolean` |  |
validations | `Validation[]` |  |
disabled | `boolean` |  |
defaultOption | `boolean` |  |

### Methods

Public fromJson
`fromJson(question: Checkbox)`
Defined in src/question/checkbox.model.ts:7
Parameters :
Name | Type | Optional | Description
question | `Checkbox` |  |
Returns : `Checkbox`

### Properties

Public defaultOption
`defaultOption: `boolean``
Type : `boolean`
Defined in src/question/checkbox.model.ts:30

    import { Answer, Dependency, Question, QuestionType } from '.';
    import { Validation } from '../validation';
    import { AnswerFactory, QuestionFactory, ValidationFactory } from '../factory';

    export class Checkbox extends Question<boolean> {

      public static fromJson(question: Checkbox): Checkbox {
        const booleanAnswer: boolean = 'true' === String(question.answer);
        'object' === typeof question.answer
          ? question.answer.value = booleanAnswer
          : question.answer = booleanAnswer;

        return new Checkbox(
          question.name,
          question.description,
          question.dependencies,
          AnswerFactory.create<boolean>(question.answer),
          ValidationFactory.createValidationList(question.validations),
          'true' === String(question.defaultOption)
        );
      }

      public constructor(
        name: string,
        description: string,
        dependencies: Dependency[] = [],
        answer: Answer<boolean> | boolean = false,
        validations: Validation[] = [],
        disabled: boolean = false,
        public defaultOption: boolean = null
      ) {
        super(name, description, QuestionType.CHECKBOX, dependencies, answer || false, validations, disabled);
      }
    }

# results matching ""

# No results matching ""