3

I'm trying to set up a demo angular app but for some reason my partial (partials/test.html) content isn't loading into the layout file. Here's the index.html:

<!DOCTYPE html>
<html lang="en" ng-app="btq">
   <head>
      <meta charset="utf-8" />
      <title>NgView Test</title>
   </head>
   <body>
      <p>Some stuff on the page.</p>
      <div ng-view></div>
      <script src="js/angular.js"></script>
      <script src="js/app.js"></script>
   </body>
</html>

AngularJS is version 1.0.7. app.js contains the following:

'use strict';

// Declare app level module which depends on filters, and services
angular.module('btq', []).
  config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/dashbaord', {templateUrl: 'partials/test.html', controller: 'DashboardCtrl'});
    $routeProvider.otherwise({redirectTo: '/dashboard'});
  }]);

/* Controllers */

angular.module('btq.controllers', []).
  controller('DashboardCtrl', [function() {

  }]);

I'm obviously missing something simple. Any help would be appreciated!

Dan
  • 59,490
  • 13
  • 101
  • 110
novon
  • 973
  • 3
  • 15
  • 30

2 Answers2

2

May be its because of "typo". You wrote "dashbaord" instead of "dashboard" here:

$routeProvider.when('/dashbaord' , ...
Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146
1

Change

angular.module('btq.controllers', [])

to

angular.module('btq')

otherwise this creates a second app in your app.js

Dan
  • 59,490
  • 13
  • 101
  • 110
  • Doing so causes the partial content to not load. Leaving it as btw.controllers loads the partial content but also throws a Error: Argument 'DashboardCtrl' is not a function, got undefined – novon Jun 09 '13 at 18:01
  • Ah I see whats wrong, I needed to pass btq.controllers to the btq module like so: angular.module('btq', ['btq.controllers']) – novon Jun 09 '13 at 18:05
  • That will work. That way you create two modules and inject the second module as a dependency in the first. Another option is to use one module for both. See my update, there was a typo in my answer. The second `[]` should not have been there. – Dan Jun 09 '13 at 18:40