AngularJS: How to nest applications within an angular app

后端 未结 5 1922
梦毁少年i
梦毁少年i 2020-12-02 09:50

i\'ve been working on a project that is more like a framework, and has several apps / modules you can install. See it like a basic appstore or google.play store. It\'s sort

5条回答
  •  有刺的猬
    2020-12-02 10:16

    well if each sub-app is in its own module, you can just use angular.bootstrap to load that module dynamically. when the url for a specific app loads, you can fetch the necessary script(s), then when the promise resolves, you can do something along the lines of:

    // grab a reference to the element where you'll be loading the sub-app
    var subapp = document.getElementById('subapp-id');
    
    // assuming the script you get back contains an angular module declaration named
    // 'subapp', manually start the sub-app
    angular.bootstrap(angular.element(subapp), ['subapp']);
    

    hope this helps

提交回复
热议问题