TypeError: Cannot add property selectedAnswer, object is not extensible

Discussão em 'Angular' iniciado por Ajinkya Kulkarni, Maio 12, 2025.

  1. Getting object not extensible error for selectedAnswer

    Object.values(atsInfo.firstLevel).forEach((subAtsInfo: any) => {
    if (subatsInfo.questions) {
    subAtsInfo.questions.forEach((ques: any) => {
    const answer = data.question_answers?.[ques.id];
    if (answer) {
    if (ques.isOnlyBool) {
    ques.isChecked = data.question_answers[ques.id] === 'yes' ? true : false;
    } else {
    var selectedItem = {
    title: data.question_answers[ques.id],
    quesId: ques.id,
    };
    ques.selectedAnswer = selectedItem;
    }
    }


    I guess this is due to object being frozen or non extensibility

    Continue reading...

Compartilhe esta Página