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