-1

JSON data contains a collection of questions on which I am trying to display in html. I used ng-repeat for looping JSON data like ng-repeat="q in response" and trying to print like

{{q.q1}}

{{q.q2}}

{{q.q3}}

Executed in chrome but data are not coming.

questionaire.json

{
    "questionaire":{
        "q1":"questionaire1 ",
        "q2":"questionaire2",
        "q3":"questionaire3"
    }
}
10
  • html and angular code : jsfiddle.net/mrajcok/7MhLd
    – sunitha b
    Jan 14, 2017 at 7:14
  • Your example works fine. MCVE is recommended.
    – 31piy
    Jan 14, 2017 at 7:21
  • not working sir , please help me jsfiddle.net/mrajcok/7MhLd
    – sunitha b
    Jan 14, 2017 at 7:23
  • You can use ng-repeat only to Arrays and not json. What is the data that you want to show, share the complete data in the question
    – Supradeep
    Jan 14, 2017 at 7:25
  • Your fiddle is working fine. What is the issue exactly ?
    – Supradeep
    Jan 14, 2017 at 7:27

2 Answers 2

0

In Your angular Controller,

$scope.json_data_sample = {

"questionaire":{
    "q1":"questionaire1 ",
    "q2":"questionaire2",
    "q3":"questionaire3"
}
};

In your html view,

<div>{{json_data_sample.questionaire.q1}}</div>
<div>{{json_data_sample.questionaire.q2}}</div>
<div>{{json_data_sample.questionaire.q3}}</div>

OR

In Html View

<div ng-repeat= "json_item in json_data_sample">
  <div>{{json_item.q1}}</div>
   <div>{{json_item.q2}}</div>
    <div>{{json_item.q3}}</div>
  </div>
6
  • here inside controller json object is thete but i create seperate json file file name is en_us.json but when loading in controller but brower is not coming
    – sunitha b
    Jan 14, 2017 at 10:27
  • traied above code still it is not coming and also updated jsfiddle can you check jsfiddle.net/7MhLd/2349
    – sunitha b
    Jan 14, 2017 at 10:42
  • The fiddle works as expected if you remove the ng-app from the body tag. Jan 14, 2017 at 11:28
  • yes i removed but still it is not coming can you show me in jsfiddle
    – sunitha b
    Jan 14, 2017 at 12:27
  • I said <body> tag. It's hidden by default, click on the HTML button. Jan 14, 2017 at 13:18
0

[You Need To clear Body tag

<body ng-app="myApp">

to

<body>

]1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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