I have a simple Angularjs app that uses route provider. The home page renders fine (including the partials), but the partials on other routes aren't getting rendered (the index page loads fine, but the section corresponding to ngView is blank). Here's what I have:
$APP_HOME/public/javascripts/app.js
angular.module('myapp', ['ngRoute', 'ui.bootstrap', 'myapp.services'])
.config([ '$routeProvider', function($routeProvider) {
$routeProvider.
when('/', {
templateUrl : 'partials/home.html',
controller : CarouselCtrl
}).
when('/add', {
templateUrl : 'partials/form.html',
controller : AddCtrl
}).
when('/about', {
templateUrl : 'partials/about.html',
controller : StaticCtrl
}).
when('/donate', {
templateUrl : 'partials/donate.html',
controller : PaymentCtrl
}).
otherwise({
redirectTo : '/'
});
} ]);
Example link in the home page:
<li><a href="#/about">About</a></li>
The partials folder has the following files:
[root@localhost partials]# ls
about.html donate.html form.html home.html
I have blank controllers for StaticCtrl and PaymentCtrl in the controllers.js file.
function StaticCtrl($scope){
}
function PaymentCtrl($scope){
}
All relevant js files have been included in the index page as well.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script>
<script src="/javascripts/app.js"></script>
<script src="/javascripts/services.js"></script>
<script src="/javascripts/controllers.js"></script>
Folder structure:
I use node.js as web server.
APP_HOME
[root@localhost]# ls
app.js node_modules package.json public README.md routes views
public:
[root@localhost public]# ls
css images javascripts partials stylesheets
javascripts:
[root@localhost javascripts]# ls
app.js controllers.js services.js
Initially, I thought it's the blank controller that's causing the issue, but it doesn't work with non-empty controllers either. Not sure what I'm missing. Please advise.