title: Store JSON data into a variable
body: <p>I am new to AngularJS. I just want to load the JSON file data into a variable that is located in factory.</p>
  
  <pre><code>myApp.factory('quizFactory', function () {
      var questions = [
          {
              "setId":1,
              "question":"What is the value of the 7 in the following number? 850,765",
              "options": ["70", "7", "7000", "700"],
              "answer": 3
          },
          {
              "setId":2,
              "question":"Is 7 &amp; 9 even or odd?",
              "options": ["Even", "Odd", "Can't Say", "Dont know"],
              "answer": 1
          },
          {
              "setId":3,
              "question":"In the number 5,281,946 what is the value of the 3rd place?",
              "options": ["100", "10,000", "1,000,000", "1,000"],
              "answer": 0 
          },
          {
              "setId":4,
              "question":"Is 12 + 50 even or odd?",
              "options": ["Even", "Odd", "Can't Say", "Dont know"],
              "answer": 0 
          },
          {
              "setId":5,
              "question":"What does the 3 represent in the number below? 3051",
              "options": ["3", "30", "300", "3000"],
              "answer": 3 
          }
      ];
  
      return {
          getQuestion: function(id) {
              if(id &lt; questions.length) {
                  return questions[id];
              } else {
                  return false;
              }
          }
      };
  });
  </code></pre>
  
  <p>The above code is stored in app.js file and my JSON file is same as the above.</p>
  
  <pre><code>[
  
  
  {
          "setId":1,
          "question":"What is the value of the 7 in the following number? 850,765",
          "options": ["70", "7", "7000", "700"],
          "answer": 3
      },
      {
          "setId":2,
          "question":"Is 7 &amp; 9 even or odd?",
          "options": ["Even", "Odd", "Can't Say", "Dont know"],
          "answer": 1
      },
      {
          "setId":3,
          "question":"In the number 5,281,946 what is the value of the 3rd place?",
          "options": ["100", "10,000", "1,000,000", "1,000"],
          "answer": 0 
      },
      {
          "setId":4,
          "question":"Is 12 + 50 even or odd?",
          "options": ["Even", "Odd", "Can't Say", "Dont know"],
          "answer": 0 
      },
      {
          "setId":5,
          "question":"What does the 3 represent in the number below? 3051",
          "options": ["3", "30", "300", "3000"],
          "answer": 3 
      }
  ];
  </code></pre>
  
  <p>I have tried <a href="https://stackoverflow.com/questions/2177548/load-json-into-variable">this question</a> too.</p>