Javascript 谁能告诉我这是怎么回事?
Javascript 谁能告诉我这是怎么回事?,javascript,angularjs,Javascript,Angularjs,我看到我们将angular作为参数传递,但是iLife收集ng,app。有人能告诉我什么是ng,app吗?我没有看到ng在何处使用?并且您不必使用这些参数。您可以在不使用参数的情况下运行此代码。然后,app变量将被隐式声明。s无需使用这些参数:)这是一段写得不好的代码,这就是为什么要添加的原因:函数中的angular使用angular作为全局变量。 (function(ng, app){ app = angular.module('app', []); app.config(f
我看到我们将
angular
作为参数传递,但是iLife收集ng,app
。有人能告诉我什么是ng,app
吗?我没有看到ng
在何处使用?并且您不必使用这些参数。您可以在不使用参数的情况下运行此代码。然后,app
变量将被隐式声明。s无需使用这些参数:)这是一段写得不好的代码,这就是为什么要添加的原因:函数中的angular使用angular作为全局变量。
(function(ng, app){
app = angular.module('app', []);
app.config(function($provide) {
$provide.constant('town', 'Burlington');
});
app.constant('name', 'Rob F.');
app.controller('MainCtrl', [
'name', 'town',
function MainCtrl(name, town) {
this.getName = function() {
return name;
};
this.getTown = function() {
return town;
};
}
]);
}(angular));