Just started dabbling in angular-js today and decided to experiment with some older examples.
I have a backend api that provides me with a json list. I am trying to fetch this data and display it on my webpage.
The examples I found were built using version 1.0.8
of angular-js and they work perfectly. However, when I attempt to replicate the same functionality using version 1.6.5
, nothing seems to work. What could be causing this issue? How can I resolve it?
Files
function Books($scope, $http) {
$http.get('http://localhost:8080/book-manager/bookslist.json').success(function(data) {
$scope.books = data;
});
}
<!DOCTYPE html>
<html ng-app>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test Angular</title>
<!-- 1.0.8 Working -->
<script src="angularjs/1.0.8/angular.min.js"></script>
<!-- 1.6.5 Not Working, Why? -->
<!-- <script src="angularjs/1.6.5/angular.min.js"></script> -->
<script src="count.js"></script>
</head>
<body>
<div ng-controller="Books">
I have {{books.length}} books!
<ul class="books-container">
<li ng-repeat="book in books">{{book.name}}</li>
</ul>
</div>
</body>
</html>