ANGULARJS Study notes the modular design of the four characteristics of 7--

Source: Internet
Author: User

Modular design

1. Refer to the custom module and call

In a custom module, if there are some services, encapsulating the funny module, in another module (at the time of declaration, add the module to be introduced in the dependency list)

var app02 = angular.module (' fan02 ', [' ng ', ' fan ']);

Call what is defined in the FAN02 module.

2.ng the use of built-in modules

(1) Ngroute module (routing module)

Angularjs is an open-source JS framework. Used in scenarios where data operations are more frequent, for spa applications

  How single-page apps work:

1. Page url:http://127.0.0.1/index.html#/Routing Address

2. The browser first parses the underlying page index.html, and then resolves the routing address

3. Find the routing dictionary, #/startàstart.html#/mainàmain.html

4. Get the Real template page address for the address of the current URL

5. Initiate an AJAX request, get the target template page, insert into the current DOM tree

 Steps to implement spa using Ngroute

1. Create a complete HTML page that introduces Angular.js, Angular-route.js

2. Create a custom module that relies on the Ng,ngroute in the dependency list

3. Declare a container in the body of the index.html (hold code snippet)

Implementation: Use the NGVIEW directive to declare a container

4. Create Code Snippets

5. Configure the Routing dictionary

$routeProvider. When ('/start ', {templateurl: ' start.html '});

6. Testing

Example: Re-correcting notes tomorrow morning

ANGULARJS Study notes the modular design of the four characteristics of 7--

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.