Answer the question
In order to leave comments, you need to log in
How to convert your AngularJS application from route-based to "static"?
Sorry for the title, but I can't think of a title myself. Lost in Angular and nothing comes to mind.
There is a ready-made application that I decided to shove into node-webkit - everything works. But with each transition along the route, the controller, templates, and so on are loaded again. We need to avoid this, i.e. get rid of routes, leave controllers that would be loaded once and maintain modularity. "Static" in this context is something similar to ordinary desktop applications.
Now the default schema is:
-index.html <div ng-view=""></div>
-app.js
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
}).
........
}
]);
Answer the question
In order to leave comments, you need to log in
Well, regarding the loading of templates - there is a templateCache, which can be collected at the project build stage. As for the controllers... how do you want it differently?
In general ... I still do not understand why this is, but I think you can do anything by replacing ngRoute with your own implementation.
If you need to save screen states, you can also hang this logic inside ngRoute or use third-party implementations.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question