forgottofly forgottofly - 2 years ago 88
Javascript Question

Parse name from the object and display-Angular Js

My object(Unparsed and raw):

$scope.result= {
"id": 2360,
"subject": "Meeting Postponed Status",
"message": "{\"name\":\"Riana\",\"status\":\"Postponed\",\"meeting\":\"Approval No 342\",\"postponedDate\":\"2015-06-24 18:30:00\",\"postponedTime\":\"13:02:57\"}",
"modifiedDate": "2015-06-29 17:09:59",
"categoryId": 1,

I'm parsing the property
object as

which outputs

$scope.result.message={"name":"Riana","status":"Postponed","meeting":"Approval No 342","postponedDate":"2015-06-24 18:30:00","postponedTime":"13:02:57"}

But if I want to bind the name
I'm not able to do it in the HTMl
I tried by giving {{}} but not able to render the name.
Is there a way to parse in the HTML as I'm unable to do it in the controller?

Answer Source

You need to assign the JSON.parse($scope.result.message) to $scope.result.message.


$scope.result.message = JSON.parse($scope.result.message);

Here's the JsFiddle link.

Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download