Reputation: 81
I am new to angularjs and i am doing simple study on angular controllers and models. this is my javascript model code.
var testApp = angular.module('testApp', []);
testApp.controller('testCtrl', function testCtrl($scope ,$http) {
$http.get('test.json').success(function ($data){
$scope.artists = $data;
});
});
The webpage is loaded but comes an exception. I am using firefox in Windows 7.
[Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 >.>(NS_ERROR_DOM_BAD_URI)" location: "file:///....// angular.min.js Line: 72"]
Does anybody knows a solution.. I dont need to make it in a server only need to use local machine..
Upvotes: 6
Views: 1583
Reputation: 4414
Check it once in chrome by disabling web securities and if the same error occur then there might be a problem in the url of json file.
Go through How can I load a local json file?
You may find what the problem is.
Upvotes: 0
Reputation: 3642
As was already mentioned in the comments above, this is likely due to Firefox's security preventing your code from gaining acces to files in your local file system.
You can configure Firefox to access local content by changing your browser's config.
In Firefox:
Upvotes: 1
Reputation:
You have to do a minor correction to the angular controller syntax.
testApp = angular.module('testApp', []);
testApp.controller('testCtrl', function($scope, $http) {
$http.get('test.json').success(function($data) {
$scope.artists = $data;
});
});
Upvotes: 1