2

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?

6
  • Can you show us your html codes? Commented Jun 29, 2015 at 12:19
  • Its like this {{result.message.name}} Commented Jun 29, 2015 at 12:23
  • What do you get for {{result}} and {{result.message}} Commented Jun 29, 2015 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 } Commented Jun 29, 2015 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"} Commented Jun 29, 2015 at 12:30

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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}}

2 Comments

@Riaj Khan the name is inside the message object
are you want to two way data binding with name?

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.