angular.js - How many parameters does a controller in AngularJs have?
phpcn_u1582
phpcn_u1582 2017-05-15 16:53:06
0
4
589
var app=angular.module("myApp",[]).controller("myController",function("这里有多少个参数"){})
phpcn_u1582
phpcn_u1582

reply all(4)
Peter_Zhu

Depending on how many parameters you inject, the general usage is as follows:

var app = angular.module('app', []);
app.controller(function($scope, $http){
    //那这个时候就只有这两个参数,这个东东在angular里叫做依赖注入。并不是默认行为,二是需要你来自己制定的,所以是多少个,就看你自己怎么用了
});
淡淡烟草味
var app=angular.module("myApp",[]);
app.controller("myController",['$scope','aService',...,function($scope,aService,...){
    //可以注入你写的factory,provider等等
}]);

  • The first parameter of the controller is the name, followed by an array. The front of the array is the content to be injected, which can be n. The last parameter is a function. The number of parameters of the function must also be n. It must be the same as the content to be injected. One-to-one correspondence
  • This is how dependency injection is implemented
習慣沉默

console.log(arguments) Take a look~

淡淡烟草味

can be n,

jsvar app=angular.module("myApp",[])
.controller("myController",['$scope','aService',...,function($scope,aService,...){
    //可以注入你写的factory,provider等等
}])
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template