0

I have a object like

private _nodeTypesProps=  {
        id: newId,
        active: false,
        name: "",
        color: "",
        character: "",
        props: {
            description: true,
            notes: true,
            lastModified: true,
            senstiveInformation: true,
            calculation: true
        }
    }

I want to read props in template

<input [(ngModel)]="_nodeTypesProps.props.description" type="checkbox" id="description"/>

Can any body help me how to read nested properties in object.

2
  • 1
    That looks right to me ... are you getting an error or something? Commented Nov 7, 2017 at 18:02
  • yes getting error description of undefined Commented Nov 7, 2017 at 18:09

1 Answer 1

1

In your template, you could use '?' to get rid of the error

<input [(ngModel)]="_nodeTypesProps?.props?.description" type="checkbox" id="description"/>
Sign up to request clarification or add additional context in comments.

2 Comments

getting further errors Unhandled Promise rejection: Template parse errors: Parser Error: The '?.' operator cannot be used in the assignment at column 37 in [_nodeTypesProps?.props?.description=$event] in AdministrationComponent@108:35
Glad it works, you can edit the answer with your final code, it could be useful! (I guess it's <input [ngModel]="_nodeTypesProps?.props?.description" (ngModelChange)="_nodeTypesProps.props.description = $event" type="checkbox" id="description"/> but if you can confirm)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.