I'm currently writing a desktop hybrid app with Electron with AngularJS integration for routing etc, please see following angular config:
app.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'partials/dashboard.html',
controller: 'dashboardController'
})
.when('/sites', {
templateUrl: 'partials/sites.html',
controller: 'sitesController'
})
.when('/sites/:site', {
templateUrl: 'partials/site.html',
controller: 'siteController'
})
.when('/sites/:site/content', {
templateUrl: 'partials/site_content.html',
controller: 'contentController'
})
.when('/sites/:site/content/create', {
templateUrl: 'partials/site_content_create.html',
controller: 'createController'
})
.when('/sites/:site/content/:contentId/edit', {
templateUrl: 'partials/site_content_edit.html',
controller: 'editController'
})
.when('/user', {
templateUrl: 'patials/user.html',
controller: 'userController'
})
.when('/user/edit', {
templateUrl: 'partials/user_edit.html',
controller: 'userEditController'
})
.when('/login', {
templateUrl: 'partials/login.html',
controller: 'loginController'
})
.when('/register', {
templateUrl: 'partials/register.html',
controller: 'registerController'
});
$routeProvider.otherwise({
redirectTo: '/'
});
});
The app loads up fine, and the initial 'dashboard.html' is injected into ng-view perfectly fine.
The problem comes when I click on an tag to load in another view, such as sites.html, for example. I get a full white screen with no errors output into the console, nor any errors coming from node.js itself.
I'm wondering whether this is a known problem, or whether I've done something wrong in my config.
Ran into this recently and thought the accepted answer was overly complicated. Simply modify
and all works as expected.
This is due to a change in AngularJS not Electron. Another solution if you do not wish to include the #! is to modify the hashPrfix in
app.config
by adding thisHere is a link to the Angular Docs for reference.
Hope this saves someone else a headache.
I've managed to overcome this issue, finally.
In the end it certainly seemed to be caused by AngularJS being a bit 'funny' about working correctly only when served by a webserver.
With that in mind, I've implemented an express server on a specific port during the 'create window' phase of my electron app. I then point the window at the localhost URL, which is now technically an express app running inside an electron app, running AngularJS.
It confused me for a while getting the setup in line, but now it seems to be working perfectly and very speedy, too.
EDIT: Here's the code for that!
main.js:
server.js: