Angularjs--module

Source: Internet
Author: User

1. Create Module

The first parameter is the name of the module var head=angular.module (' Headapp ', []); Head.controller ("User", "$scope", function ($scope) {$scope. Username= "admin"; $scope. Logintime=new Date (). toString ();}]);

2. Create module and rely on other module

Create module and this module depends on other modules//the second parameter is dependent on the block name if you do not rely on any modules to pass an empty array []. Note: If the second argument is not passed, it is the module var my=angular.module (' myApp ', ["Headapp"]) that gets the current name, My.controller ("Content", ["$scope", function ($scope) {$scope. Text= "This is a test page";}]);

3, different module has the same controller when the call mode

If the current module and the dependency have the same controller, the controller for the current module is called. When the current module does not have this controller, the controller//in the dependent module is called to comment (or uncomment) the following controller code, depending on the effect of the page//My.controller ("User", ["$scope ", function ($scope) {//$scope. Username= "admin123";//$scope. Logintime= "2015-7-25";//}]);

  

The

Demo code is as follows:

<! DOCTYPE html>

  

Poke Code test Address

Angularjs--module

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.