Notes for AngularJs compression and AngularJs Compression

Source: Internet
Author: User

Notes for AngularJs compression and AngularJs Compression
AngularJS uses the parameter name of the controller constructor to infer the dependent service name. Therefore, if you want to compress the Controller's JS Code, all its parameters will be compressed at the same time. At this time, the dependency injection system cannot correctly identify the service.

Assume that the name of our Controller is BookCtrl, and the code before compression is:
Var BookCtrl = function ($ scope, $ http) {/* constructor body */};

To overcome the problems caused by compression, you only need to assign an array of dependent service identifiers to the $ inject attribute in the controller function:
BookCtrl. $ inject = ['$ scope', '$ http'];

Another method can also be used to specify the dependency list and avoid compression problems-use Javascript arrays to construct the controller: Put the service to be injected into a String Array (representing the dependency name, the last element of the array is the Controller's method function:

Var BookCtrl = ['$ scope', '$ http', function ($ scope, $ http) {/* constructor body */}];


The two methods mentioned above can work perfectly with any function that AngularJS can inject. Which method to choose depends entirely on the programming style of your project. We recommend that you use arrays.
Select echo of AngularJs

I don't know what your aa and some data formats are like. The following is a selected example:
<! DOCTYPE html>
Establish an AngularJS Environment

Pay attention to the following key areas,
1. Add ng-app
2. Introduce angularjs.
See angularjs.org/here for details.
<! Doctype html>

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.