Part 2 Angular modules and controllers

Source: Internet
Author: User

What's a module in AngularJS?

A module is a container for different parts of your application i.e controllers,services,directives,filters,etc.

You can think the A module as a Main () method in the other types of applications.

How to create a module?

Use the Angular object's module () method to create a module.

var myApp = Angular.module ("MyModule", []); //

What's a controller in angular?

In angular a controller is a JavaScript function. The job of the controller is to build a model for the view to display.

How to create a controller in angular?

var function ($scope) {    $scope. Message= "AngularJS Tutorial";    };

How do I register the controller with the module?

Myapp.controller ("Mycontroller", Mycontroller);           //   1-Myapp.controller ("Mycontroller",function($scope) {       //  2-     $scope. message= "AngularJS Tutorial";    });

In JS file, we can add a reference with Angular.js to have some code tip. (AutoComplete some angular member.)

Part 2 Angular modules and controllers

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.