4

I'm guessing there must be something obvious I have missed, this is the second angular app I am building and I have never had this issue before..

Seems both of my controllers are receiving this error. I have confirmed that controllers.js gets loaded and console.log(angcomControllers) does return an object. Other than that I am lost.

index.html:

<!doctype html>
<html class="no-js" lang="en" data-ng-app="angcomApp">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Foundation</title>
    <link rel="stylesheet" href="stylesheets/app.css" />

    <!--Library/Framework JS-->
    <script src="bower_components/jquery/jquery.js"></script>
    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/angular-animate/angular-animate.js"></script>
    <script src="bower_components/angular-resource/angular-resource.js"></script>
    <script src="bower_components/angular-route/angular-route.js"></script>

    <!--script src='https://cdn.firebase.com/v0/firebase.js'></script>
    <script src='https://cdn.firebase.com/libs/angularfire/0.5.0/angularfire.min.js'></script-->

    <!--App JS-->
    <script src="js/app.js"></script>
    <script src="js/animations.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/filters.js"></script>
    <script src="js/services.js"></script>
     <script src="js/directives.js"></script>
  </head>
  <body>

    <div ng-view class="view-frame"></div>

  </body>
</html>

app.js

'use strict';

var angcomApp = angular.module('angcomApp',[
    'ngResource',
    'ngRoute',

    'angcomControllers',
    'angcomServices',
]);

angcomApp.config(['$routeProvider', function($routeProvider) {

        $routeProvider.when('/items', {
            templateUrl: 'partials/items.html',
            controller: 'itemsController'
        }).when('/categories', {
            templateUrl: 'partials/categories.html',
            controller: 'categoriesController'
        });
}]);

controllers.js

var angcomControllers = angular.module('angcomControllers', ['angcomServices']);

angcomControllers.controller('itemsController' ['$scope', 'Items', function($scope, Items) {

}]);

angcomControllers.controller('categoriesController' ['$scope', function($scope) {

}]);

items.html

<div data-ng-controller="itemsController"></div>

If I need to post any more code please let me know, thanks!

1 Answer 1

6

You are missing ,:

angcomControllers.controller('itemsController', ['$scope', 'Items', function($scope, Items){

}]);
Sign up to request clarification or add additional context in comments.

5 Comments

There are a lot of commas there. Could you please clarify which one was missing?
@MichaelScheper commas are missing when declaring controllers, after controller name
Thanks. It turned out to be quite a different problem in my case.
@MichaelScheper What was the actual problem (aside from the comma)?
@alukach: Sorry; I'm afraid I can't remember, otherwise I would've specified. It might've been a typo in my controller name, or I might've forgotten to put something in quotation marks. More web searching helped make it clear just how vague this error is and how many possible causes there are. I eventually found the problem just by looking at my code for the fifth or sixth time, and saying 'd'oh!!' ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.