About Requirejs is nothing here to explain, only with pure code combat to let you feel requirejs rely on the powerful management.
First, to download the require.js, and then the entire import file Main.js includes references to other JS.
Configuration dependent require.config ({ paths: { "angular": "Angular" }, shim:{ "angular": { "deps": [], " exports": "Angular"}} ); /define module define ([ ' angular ', ' controller ' ], function (angular) { angular.module (' Hellomodel ', [' Helloctrls ']); return { angularmodules: [' Hellomodel ' }; });
Second, define the controller module in the angular controller.js
define ([' angular '], function (angular) { var componentctrls = angular.module (' Helloctrls ', []); Componentctrls.controller (' Helloctrl ', [' $scope ', function ($scope) { $scope. greet = "Hello World"; }]); return componentctrls;});
III. Create a new index.html file test
<! DOCTYPE html>
IV. Organizational structure of documents
The Simplest demo example, you can have a good one! Later may revise, also welcome everybody to advise O (∩_∩) o~
Using Requirejs to manage Angularjs dependency examples