0

Return json form the API which is

    { ACC: "{"NO":"AC307","NAME":"joe"}, RETURN: "TRUE" }

i need the value separate as NO, NAME , ... how can i

HTML:

  <div ng-repeat="acdetails in accdetails ">
        <div class="item item-divider item-input-wrapper">
           Acc No - {{ acetails.NO }}
        </div>
         <div class="item item-divider item-input-wrapper">
            Name&nbsp; - {{ acdetails.NAME }}
        </div>
   </div>

but its displaying as empty , i am new to angular help me out

Thank you in advance

3
  • show us how you populate acedetails. Plus, look out for spelling, you have acedetails and acdetails in the HTML Commented Aug 25, 2015 at 13:51
  • ya i have updated its a mistake then also it remain same values are empty Commented Aug 25, 2015 at 13:54
  • There is no array shown in api data. What are you trying to repeat over? Show more code. You either haven't shown us your data properly or you have a data structure problem Commented Aug 25, 2015 at 13:58

4 Answers 4

1

The JSON is invalid. Assuming that in your angular controller you have the following (note that this is an array of objects)

$scope.accdetails =  [{ 
    "ACC": {
        "NO":"AC307",
        "NAME":"joe",
    },
    "RETURN": "TRUE" 
}];

then the following html displays the desired information

    <div ng-repeat="acdetails in accdetails">
        <div class="item item-divider item-input-wrapper">
           Acc No - {{ acdetails.ACC.NO }}
        </div>
         <div class="item item-divider item-input-wrapper">
            Name&nbsp; - {{ acdetails.ACC.NAME }}
        </div>
    </div>
Sign up to request clarification or add additional context in comments.

1 Comment

Good approach by hard coding a set of values. Now OP can work on fixing back end to match
0

try Changing Acc No - {{ acetails.NO }} to Acc No - {{ acetails.ACC.NO }}

1 Comment

While this code may answer the question, it would be better to explain how and why it works.
0

You JSON is not valid. Valid json below

{"ACC": {
    "NO": "AC307",
    "NAME": "joe",
    "ST": "",
    "RETURN": "TRUE"
} }

1 Comment

i have some thing like this { ACC: "{"NO":"AC307","NAME":"joe"}, RETURN: "TRUE" } how can i get
0

I found the solution for this

Actual RETURN DATA:

  { ACC: "{"NO":"AC307","NAME":"joe"}, RETURN: "TRUE" }

just in your controller use json parse

 .success(function(data) {   
            if(data.RETURN == "TRUE") {                    
                var acdetailsObject = JSON.parse(data.ACC);
                $scope.acdetails = acdetailsObject;                                               
            }

your data will be as format below

       { NO: "AC00316", NAME: "John Doe" }

then in your html you can directly fetch using $scope.acdetails with out using any ng-repeat , as below

  <div class="item item-divider item-input-wrapper">
       Acc No - {{ acdetails.NO }}
    </div>
     <div class="item item-divider item-input-wrapper">
        Name&nbsp; - {{ acdetails.NAME }}
    </div>
</div>

Comments

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.