Muli Yulzary Muli Yulzary - 5 months ago 10
Node.js Question

Some weird issue with template loading

I'm trying to implement HTML5 push state in my angular app but to no avail.

Things seem to work fine (I can access every static file from the browser by typing the exact path (an example would be

http://localhost/components/profile/profile.html
) but when I try to load template through
templateUrl
option in state definiton it's not loading anything. No errors in the console neither. Are my routes set up correctly?

Worth mentioning: when switching to
profile
state I see
profile.js
request in the server, but no request for the template.

Express routes:

app.use('/', express.static(__dirname + '/public'));
app.get('/[^\.]+$', function(req, res){
res.sendFile("index.html", { root: __dirname + '/public' });
});


App config:

function lazyLoad(pathjs) {
return ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load(pathjs);
}];
}

$stateProvider
.state('home', {
url: '/',
template: 'Welcome home'
})
.state('profile', {
url: '/profile',
templateUrl: 'components/profile/profile.html',
controller: 'profileCtrl',
controllerAs: 'vm',
resolve: {
module: lazyLoad('components/profile/profile.js'),
user: ['SessionService', function (SessionService) {
return SessionService.currentUser();
}]
}
});

$locationProvider
.html5Mode(true)
.hashPrefix('!');


Project tree:

Project tree

Answer

The issue was unresolved promise in the resolve clause.

Comments