B
B
buzzi8882014-06-28 22:29:42
Ruby on Rails
buzzi888, 2014-06-28 22:29:42

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'
        }).
       ........
    }
]);

Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
4
4itosik, 2016-02-29
@IsaevAlex

The problem is 5.times { product.photos.build }in the edit action.

S
Sergey, 2014-06-28
Protko @Fesor

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 question

Ask a Question

731 491 924 answers to any question