Dynamic modul loading

In ionic v1 it was possible to load modules dynamically from a remote apache server. We didn’t have to install the modules’ sources with the application, we could store them (controller js, html, resource files etc) on an apache server folder and we downloaded them dynamically when we needed them.

In this way, we could install a very simple application to the mobile devices, which could request the side menu item list from an applications server with a service call and download the needed modules at start-up. The service call response defined the menu item name, the needed resource files and the template URL etc… The needed resource files were loaded with oc.lazyLoad and the templates were added using templateProvider:

                  "state":{
                      url: '/newsList',
                      cache: false,
                      views: {
                        'menuContent': {
                          controller: 'NewsCtrl',
                          templateProvider: function($http, $templateCache) {
                                  var templateName = 'http://…/news/templates/news_list.html';
                                  var tpl = $templateCache.get(templateName);
                                  if(tpl){
                                    return tpl;
                                  }

                                  return $http
                                     .get(templateName)
                                     .then(function(response){
                                        tpl = response.data
                                        $templateCache.put(templateName, tpl);
                                        return tpl;
                                    });
                              }
                        }
                      }
                  }

Is it possible to implement similar solution in ionic v2?

“Impossible” is a very high standard, but Angular 2 really really wants all code available at build time, so I would recommend giving up on this idea. Also, if I were Apple or Google, I would reject any app that does this, because neither I nor the end-user has any way of auditing the app’s security.

1 Like

Thank you for your answer! Our current application didn’t have to be verified by Google, because it is an internal application, it is not in the public store.
The solution I explained, works with ionic 1. We were thinking if we could upgrade to ionic 2 in a way we can keep this functionality.
The reason I doubted it is the mechanism how ionic 2 makes the build (sources transpiled to javascript). Anyway, the “Impossible” is good enough answer for me.

@bakondis Did U manage to achieve this functionality, dynamic module loading during run time?