I'm learning AngularJS and Json and have a small page that needs to display data retrived from .json file in controller.
When opening the page I have error:
Unexpected token t at Object.parse (native)...
This is my html:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="../Scripts/angular.min.js"></script>
<script src="../Scripts/Controllers/app.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="PostsCtrl">
<ul ng-repeat="post in posts">
<li>{{post.title}}</li>
</ul>
</div>
</body>
</html>
This is a controller:
var app = angular.module('myApp', []);
app.controller("PostsCtrl", function ($scope, $http) {
$http.get('data/posts.json').
success(function (data, status, headers, config) {
$scope.posts = data;
}).
error(function (data, status, headers, config) {
});
});
This is .json
[
{title: "Title1"},
{title: "Title2"},
{title: "Title3"}
]
I'm not sure why I get an error.