getting values from ts file in html

11 views
Skip to first unread message

Sandeep Shukla

unread,
Jun 23, 2020, 11:09:56 AM6/23/20
to Angular and AngularJS discussion
I am new in angular, I would like to display the values in html , 
{
    "error": null,
    "document": {
        "title": "Hello World Angular",
        "heading": "subject to changes"
    },
    "versions": [
        {
            "attributes": {
                "sequence": "1",
                "versionNumber": "1.6",
                "id": "A00100"
            },
            "contentElements": [
                {
                    "contentType": "BASE",
                    "mediaType": "text/xml",
                    "fileName": null,
                    "size": 779,
                    "content": "This is content"
                },
                {
                    "contentType": "NOTELOG",
                    "mediaType": "text/plain",
                    "fileName": null,
                    "size": 29,
                    "content": "Content2"
                }
            ]
        }
    ]
}
I have difficulty in accessing the values from versions onwards.

Regards
Sandeep 
     
  

Luis Mejias

unread,
Jun 25, 2020, 8:54:28 AM6/25/20
to ang...@googlegroups.com
Hi , 
This way you should be able to access,
public test = {
        "error": null,
        "document": {
            "title": "Hello World Angular",
            "heading": "subject to changes"
        },
        "versions": [
            {
                "attributes": {
                    "sequence": "1",
                    "versionNumber": "1.6",
                    "id": "A00100"
                },
                "contentElements": [
                    {
                        "contentType": "BASE",
                        "mediaType": "text/xml",
                        "fileName": null,
                        "size": 779,
                        "content": "This is content"
                    },
                    {
                        "contentType": "NOTELOG",
                        "mediaType": "text/plain",
                        "fileName": null,
                        "size": 29,
                        "content": "Content2"
                    }
                ]
            }
        ]
    }
this.test.versions.forEach((element)=>{
                console.log('ELEMENT 'element.contentElements);

            })
Regards.

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/aa686158-6907-458c-9baa-9bb62633e7e9o%40googlegroups.com.


--
Luis Alexander Mejías Aular.
Reply all
Reply to author
Forward
0 new messages