Manuel Stoilov Manuel Stoilov - 1 month ago 9x
AngularJS Question

AngularJS - getting "Uncaught Error: [$injector:modulerr]" message on a simple app

I'm following along with Linkster's online tutorial that shows how to make a reddit clone using the MEAN stack. (

I've gotten to a point where I've tried everything, but nothing seems to be working. Any ideas what's wrong? Any help/ideas are appreciated :)


<title>Welcome to FlapperNews!</title>
<link type="text/css" rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>

<script src="app.js"></script>
<style> .glyphicon-thumbs-up { cursor:pointer } </style>
<body ng-app="flapperNews" ng-controller="MainCtrl">
<div class="row">
<div class="col-md-6 col-md-offset-3">

<script type="text/ng-template" id="/home.html">
<div class="page-header">
<div ng-repeat="post in posts | orderBy: '-upvotes'">
<span class="glyphicon glyphicon-thumbs-up" ng-click="incrementUpvotes(post)"></span>
<span style="font-size:20px; margin-left:10px;">
<a ng-show="" href="{{}}">
<span ng-hide="">
-upvotes: {{post.upvotes}}
<form ng-submit="addPost()"
<h3>Add a new post</h3>

<div class="form-group">
<input type="text" class="form-control" placeholder="title" ng-model="title"></input>
<div class="form-group">
<input type="text" class="form-control" placeholder="Link" ng-model="link"></input>
<button type="submit" class="btn btn-primary">Post</button>


var app = angular.module('flapperNews', ['ui-router']);
function($stateProvider, $urlRouterProvider){

.state ('home', {
url: "/home",
templateUrl: "/home.html",
controller: 'MainCtrl'

// .state('posts', {
// url: '/posts/{id}',
// templateUrl: '/posts.html',
// controller: 'PostsCtrl'
// });


app.factory('posts', [function(){
var o = {
posts: [{title: 'hello post1', link: '', upvotes: 0 }]
return o;

app.controller('MainCtrl', [
function($scope, posts){
$scope.test = 'Hello world!';

$scope.posts = posts.posts;

$scope.addPost = function(){
if(!$scope.title || $scope.title === '') { return; }
title: $scope.title,
link: $,
upvotes: 0});
$scope.title = '';
$ = '';

$scope.incrementUpvotes = function(post) {
post.upvotes += 1;


Try var app = angular.module('flapperNews', ['ui.router']); instead of var app = angular.module('flapperNews', ['ui-router']);