Using Requirejs to manage Angularjs dependency examples

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.