My code was working until I started the service portion of the project. Even {{helloWorld}} in the view does not appropriately appear with its contents.
Here is the current page that I am at: https://www.codecademy.com/final_project/learn-angularjs
Under “Display The Contents Of The Service” was the last instruction I’ve followed. Please point out anything inaccurate that you see.
Thank you.
index.html
<!DOCTYPE html>
<head>
<title>Suggestion Box</title>
<meta charset="utf-8">
<script type="text/javascript" src="js/vendor/angular.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body ng-app="SuggestionBox">
<div class="main" ng-controller="HomeController">
<div class="container">
<h1>{{helloWorld}}</h1>
<div class="col-md-6" ng-repeat="post in posts">
<p class="title"> {{ post.title }}></p>
<p class="upvotes"> {{post.upvotes}}></p>
</div>
</div>
<!--Modules-->
<script type="text/javascript" src="js/app.js"></script>
<!--Controllers-->
<script type="text/javascript" src="js/controllers/HomeController.js"></script>
<!--Services-->
<script type="text/javascript" src="js/services/suggestions.js"></script>
</body>
</html>
HomeController.js
app.controller("HomeController", ["$scope", "suggestions", function($scope, suggestions){
$scope.helloWorld = "Hello, AngularJS!";
$scope.posts = suggestions.posts;
}]);
suggestions.js
app.factory('suggestions', [function(){
var demoSuggestions = {
posts: [
{
title: 'Free pizza at club meetings',
upvotes: 15,
comments: [],
},
{
title: 'End all club emails with Laffy Taffy jokes',
upvotes: 9,
comments: [],
},
{
title: 'Retrofit water fountain with Gatorade',
upvotes: 7,
comments: [],
},
{
title: 'Sing Bon Jovi\'s "Living on a Prayer" halfway through meetings,
upvotes: 3,
comments: [],
},
]
};
return demoSuggestions;
}]);
app.js
var app = angular.module("SuggestionBox",[]);