0
也许我错过了某些特定的角度或JavaScript需要这个,但有人可以解释是否有技术原因CarWashService定义两次以下?IIFEs和命名约定
(function() {
angular.module("cw.services")
.factory("CarWashService", ['$sce', '$rootScope', function ($sce, $rootScope) {
var CarWashService;
return new (CarWashService = (function() {
function CarWashService() {
this.results = [];
this.resultsCountText = "";
this.PageIndex = 0;
this.processing = false;
this.initialized = false;
this.showNoResults = false;
this.showResults = false;
this.noCarWashMessage = $sce.trustAsHtml($rootScope.resources.landingNoCarWashMessage);
}
return CarWashService;
})());
}]);
}).call(this);
什么可以扔我离开时在同一行调用return new
如被分配CarWashService。对于那些JavaScript大师来说,在IIFE中使用除CarWashService以外的其他名称是否合理?或者在做IIFE时这是一种可接受的模式?
这看起来太复杂了,没有更多。 – deceze