javascript - JSON and Angular -


i looking @ other posts importing json angular application , can't seem work. format of json.

    {       "info": [          {           "name" : "test",           "age" : 26         }       ]     } 

this have in regard controller:

       var app = angular.module("app", []);        app.controller('testcontroller', function($scope, $http){           $scope.tests = [];           $http.get('test.json')             .then(function(res){                 $scope.tests = res.data;          });         }); 

and have in html:

     <head>        <title></title>          <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.js"></script>          <script src="./javascripts/application.js" type="text/javascript"></script>      </head>        <body ng-app="app">          <div ng-controller="testcontroller">             <div ng-repeat="test in tests">                <h1 >{{test.name}}</h1>                <h2 >{{test.age}}</h2>                   </div>          </div>       </body> 

when open html file in browser data not render. instead written in curly braces.

$http.get makes ajax call url specify. should hosted on proper web server (node.js example) . way have it, not getting response test.json because not served properly.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -