Jump to content

json file read in root folder in angular js


danishwebindia

Recommended Posts

My Customers.JSON file in root folder. its not working.

 

My code is

 

<div ng-controller="personName">
<input type="text" ng-model="test" />
<ul class="list-unstyled">
<li ng-repeat="x in names | orderBy:'Name' | filter:test">{{x.Name+' '+x.City}}</li>
</ul>
</div>
<script type="text/javascript">
function personName($scope,$http){
$http.get('Customers.JSON').success(function(response){$scope.names=response;});
}
</script>

 

Link to comment
Share on other sites

Your browser might have a security restriction to not load local files with Javascript. If you just double-click on a file to open it in a browser it will run with a restricted set of permissions. You might want to install a local test server so that you can run it through a server locally.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...