title: Can I change which JSON file is loaded by sending a variable to AngularJS?
body: <p>I would like to load the content of one of two JSON files, food1.json or food2.json. I am trying to do this from the html template: </p>
  
  <pre><code>  &lt;body ng-controller="MainCtrl" ng-init="init('food1')"&gt;
  </code></pre>
  
  <p>And then in the JS:</p>
  
  <pre><code>$scope.init = function (name) {
      $scope.name = name;
      $scope.category = name + ".json";
      $scope.foodlist = {};
      $http({
          method: 'GET',
          url: $scope.category,
      }).success(function (data, status, headers, config) {
          {
              $scope.foodlist = data;
          }
      }).error(function (data, status, headers, config) {
          // something went wrong :(
      });
  };
  });
  </code></pre>
  
  <p>The category name is properly assembled: I get "I am food1" if I print <code>I am {{ category }}</code>. But no food items are printed. I think I am doing the JSON call wrong. </p>
  
  <p><a href="http://plnkr.co/edit/DZy5H7UxGHQlnfcqFr26?p=preview" rel="nofollow">Here's my Plunkr</a></p>