Angular JS's inline Array annotation understanding

Source: Internet
Author: User

The form of the inline Array annotation is:

somemodule. ( ' Mycontroller ' , [ ' $scope ' ,  ' greeter ' Span class= "pun" >, function ( $scope , Greeter)  {  //... }]); 
where function ($scope, greeter) {} represents the $scope object, respectively, Greeter object.

Now I'm going to change the code above:
someModule.controller(‘MyController‘, [‘$scope‘, ‘greeter‘, function(a,b) { // ...}]);
其中参数a代表的是$scope对象,参数b代表的是greeter对象,至于我们在开发时把参数和和参数所代表的对象取相同的名字是为了见名知义。
下面的代码是参数的名字和对象名字不一致的情况:
<! DOCTYPE html>"en">"UTF-8"> <title>Title</title>".. /materialdesignfile/angular.js"></script> <script>Angular.module ('myApp', []). Factory ('MyService', function () {varfactory={}; Factory.name="Ouyangfeng"; Factory.sayhello=function () {Debugger Console.log ("Say hello"); }               returnFactory; })
Sixi represents the object that $scope,ouyangfeng represents: MyService. . Controller (
'Myctrl',['$scope','MyService', Function (Sixi,ouyangfeng) {Sixi.sixi="Si Xi"; Debugger Sixi.hello=Ouyangfeng.sayhello; Sixi.name=Ouyangfeng.name; }]); </script> <div ng-app="myApp"Ng-controller="Myctrl"> "Hello ()">hello</button>

 
 

Angular JS's inline Array annotation understanding

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.