ng-view not working with partials in AngularJS/Express

拥有回忆 提交于 2019-12-01 18:43:55

Not sure how much this will help but I notice all the bower packages are in the 'bower_components' directory. That is the default for bower unless you specify another directory. So, if you want the bower components installed say, '/public/vendor', do the following:

1) create a file called ' .bowerrc ' and save it in your root directory ie. with gitignore, bower.json, etc.

2) in the file put:

{
  "directory": "public/vendor"
}

That will load the bower components where you want them. The file ' .bowerrc ' is a config file for bower and you can find the guidance at: http://bower.io/

HTH

Thers is something off in your app.js file. Replace it with this and you should be good to go:

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

angular.module('app').config(function($routeProvider, $locationProvider){  
    $locationProvider.html5Mode(true);
    $routeProvider
        .when('/', { templateUrl: '/partials/main', controller: 'mainCtrl'});
});


angular.module('app').controller('mainCtrl', function($scope){  
    $scope.myVar = "Hello Angular";
});
  app.get('*', function(req, res,next) {
     if(req.xhr != true)
       {
         res.render('index');
       } else
       {
       next();
    }
        });

modify like this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!