Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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>

angular.js 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!

share|improve this question

2 Answers

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

$routeProvider.when('/dashbaord' , ...
share|improve this answer
 
There was definitely a typo, can't believe I didn't catch that. Thanks! –  novon Jun 9 at 17:59

Change

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

to

angular.module('btq')

otherwise this creates a second app in your app.js

share|improve this answer
 
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 9 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 9 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. –  sh0ber Jun 9 at 18:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.