2

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.

user1452030
  • 1,001
  • 3
  • 10
  • 18

2 Answers2

0

You are putting app.js in

$APP_HOME/public/partials/app.js

and relatively going to partials so you are searching for

$APP_HOME/public/partials/partials

move up a level app.js or take out the partials part of the paths

EDIT----

can you try preppending '/' to the templates paths?

Santiago Rebella
  • 2,399
  • 2
  • 22
  • 29
0

I tried tracing my GET requests and apparently, the partials ARE loading fine, but the content was hidden behind the bootstrap navbar. My home page has a carousel control and though a portion of that has been tucked under the navbar, it was visible, but for the other partials, they were a few lines of text, which weren't visible, at all.

Now, I need to figure out why the ngView is tucked under the navbar, but I guess that's outside the scope of this question.

Thanks everyone, for your time and support.

user1452030
  • 1,001
  • 3
  • 10
  • 18