5

I'm getting an uncaught object error in my console when trying to load my angularjs app. I don't know if it's related to ng-route.js or not, but that's all the error tells me is uncaught object

Here's my Code

HTML

<!doctype html>
<html class="no-js" lang="en" ng-app="selfservice">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Foundation</title>
    <link rel="stylesheet" href="css/app.css" />
    <script src="bower_components/modernizr/modernizr.js"></script>
    <script src="bower_components/angular/angular.min.js"></script>
    <script src="bower_components/angular-route/angular-route.min.js"></script>
    <script src="bower_components/jquery/dist/jquery.min.js"></script>
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
  </head>
  <body>
    <div id="template">

        <div id="view">
            <ng-view></ng-view>
        </div>

    </div>

    <script src="bower_components/foundation/js/foundation.min.js"></script>
    <script>
        //initialize foundation
        $(document).foundation();
    </script>
  </body>

app.js

//Initialize angular module include route dependencies

var app = angular.module("servicedesk", ['ngRoute']);

app.config(function ($routeProvider) {
   $routeProvider
       .when('/', {
           templateUrl:"partials/login.html",
           controller:"login"
       });
});

controller.js

app.controller("login", function ($scope) {
    return "";
});
richbai90
  • 4,994
  • 4
  • 50
  • 85
  • Not sure if this would solve your problem or not but `ng-app="selfservice"` should be `ng-app="servicedesk"` – Anthony Chu May 28 '14 at 21:04
  • You're right I missed that. That did fix it. The error was caused by a missing dependency on my module, thought the dependency wasn't missing, the name declaration for my module was wrong. Thanks. Post it as an answer so I can accept it – richbai90 May 28 '14 at 21:07

2 Answers2

4

ng-app should contain the name of the module. Change ng-app="selfservice" to ng-app="servicedesk".

Anthony Chu
  • 37,170
  • 10
  • 81
  • 71
3

Angular-route is a separated module, you need to include it inside your servicedesk module declaration like this :

var app = angular.module("servicedesk", ["ngRoute"]);