Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

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 message of $scope.result object as

$scope.result=JSON.parse($scope.result.message); which outputs $scope.result.message as

$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 Riana I'm not able to do it in the HTMl I tried by giving {{result.message.name}} 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?

share|improve this question
    
Can you show us your html codes? – Alberto I.N.J. Jun 29 at 12:19
    
Its like this {{result.message.name}} – forgottofly Jun 29 at 12:23
    
What do you get for {{result}} and {{result.message}} – Stu Jun 29 at 12:23
    
For {{result}}: { "subject": "Meeting Postponed Status", "message": "{\"name\":\"RianaMinny\",\"status\":\"Postponed\",\"meeting\":\"Approval of Mining Site area No 342\",\"postponedDate\":\"2015-06-24 18:30:00\",\"postponedTime\":\"13:02:57\"}", "modifiedDate": "2015-06-29 17:09:59", "categoryId": 1 } – forgottofly Jun 29 at 12:26
    
and {{result.message}} :{"name":"Riana","status":"Postponed","meeting":"Approval No 342","postponedDate":"2015-06-24 18:30:00","postponedTime":"13:02:57"} – forgottofly Jun 29 at 12:30

2 Answers 2

up vote 1 down vote accepted

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

E.g.

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

Here's the JsFiddle link.

Hope it helps.

share|improve this answer

Well after this statement.

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

your $scope.result object look this

Object {name: "Riana", status: "Postponed", meeting: "Approval No 342", postponedDate: "2015-06-24 18:30:00", postponedTime: "13:02:57"}

In HTML you should use like this

{{result.name}} and

not like this one {{result.message.name}}

share|improve this answer
    
@Riaj Khan the name is inside the message object – forgottofly Jun 29 at 12:33
    
are you want to two way data binding with name? – RIYAJ KHAN Jun 29 at 12:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.