search

Home  >  Q&A  >  body text

angular.js - How to load css js of different templates in angularjs

How can the different js and css used in each template be loaded on demand? Can they be combined into one file? In addition, is angularjs suitable for mobile development? The file feels very large.

滿天的星座滿天的星座2862 days ago660

reply all(3)I'll reply

  • PHPz

    PHPz2017-05-15 16:55:18

    angular is still too heavy for mobile devices.

    Consider using requirejs or seajs for on-demand loading of js.

    The on-demand loading of css can only be split into individual css by module and then referenced on demand. Look at the module granularity.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 16:55:18

    angular itself does not handle file loading.
    If you need to load each file on demand, consider using require.js or sea.js

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-15 16:55:18

    angular does not require require.js
    Just declare in your app that the required modules are loaded when you use them.
    For example, I declared in testCotroller

    APP.controller('test',[$http,'myjsfunc'],function(){
        //your code
    })
    

    Then in the html code, as long as the page using the test controller introduces the js of the myjsfunc module written by yourself (it may be service, filter, etc., or you can manually encapsulate it into an angular module, you can not encapsulate it, angular will complete the js after the js is completed) bootstrap) can complete on-demand loading

    reply
    0
  • Cancelreply