0

I have a trouble with my phones.json file. I added Folder phones and phones.json into my project.

phones.json

I wrote homeController.js:

var phonecatApp = angular.module("phonecatApp", []);

phonecatApp.controller('PhoneListCtrl',['$scope', '$http', function($scope,$http) {
    $http.get('../phones/phones.json').success(function (data) {
        $scope.phones = data;
    });

     $scope.orderPror = 'age';
}]);

after running a project i have error: exception

Why does it fail to load phones.json? Thanks for your answers.

3
  • try this ./phones/phones.json Commented Feb 29, 2016 at 9:05
  • Can you also show where did you place your homeController.js? Commented Feb 29, 2016 at 9:10
  • my homeController be in Controllers folder. Commented Feb 29, 2016 at 9:12

2 Answers 2

1

Thanks guys for your answers, i done it, i just add to Web.config the next code:

<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8"/>
    </staticContent>
   .....
  </system.webServer>
Sign up to request clarification or add additional context in comments.

1 Comment

Ha! That explains it. Glad you got it sorted and thanks for posting the answer.
0

There's nothing wrong with your code, so it must be the path.

Have you tried opening http://localhost:6059/phones/phones.json directly in your browser? By the error you're seeing, opening it directly in your browser should also result in a 404.

I would also suggest trying to reference the file from your site's root path:

$http.get('/phones/phones.json').success(function (data) {

If that doesn't work then I'd suggest looking at assets that are successfully loading (such as an image) and check the path for those and see if you're able to navigate to the phones.json file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.