1
我在firebug中出現錯誤。 錯誤:[$ injector:modulerr]由於以下原因無法實例化模塊autoQuote: [$ injector:pget]提供方函數prepareDtoFactory()'必須定義$ get factory方法。
我的代碼爲angualr js控制器如下。
angular
.module("autoQuote")
.controller(dtoController)
.factory(prepareDtoFactory);
function dtoController(prepareDtoFactory){
prepareDtoFactory.rc1Step1DTO(); //call function from your service, and do something with it
}
dtoController.$inject = ['prepareDtoFactory'];
function prepareDtoFactory(){
var prepareAutoQuoteDTO = {
postAutoQuoteObj : $.getAutoQuoteObject(),
initializeDriverObj: function(){
var driverLocObj = new Driver();
driverLocObj.PersonInfo = new PersonInfo();
driverLocObj.DriverLicense = new DriverLicense();
driverLocObj.Incident = new Incident();
return driverLocObj;
},
initializeAppInfo: function(){
var appInfoLocObj = new ApplicationInfo();
appInfoLocObj.Discount = new Discount();
return appInfoLocObj;
},
/*
* Initialize Vehicle object for autoQuoteDTO.js
*/
initializeVehicleObj: function(){
var vehicleLocObj = new Vehicle();
return vehicleLocObj;
},
/*
* store session info
*/
rc1Step1DTO: function(){
var emailId = $('#save_quote_email').val();
if (typeof emailId !== "undefined" && emailId && emailId != '' && emailId != 'Email Address'){
var email = new Email();
email.EmailTypeCd = 'PRIMARY';
email.EmailAddress = emailId;
this.postAutoQuoteObj.ApplicationInfo.GeneralPartyInfo.ContactInfo = this.postAutoQuoteObj.ApplicationInfo.GeneralPartyInfo.ContactInfo || new Contact();
this.postAutoQuoteObj.ApplicationInfo.GeneralPartyInfo.ContactInfo.Emails = [];
this.postAutoQuoteObj.ApplicationInfo.GeneralPartyInfo.ContactInfo.Emails.push(email);
}
}
};
return prepareAutoQuoteDTO;
}
與所有的文件創建plunker
請幫我解決這個錯誤。 http://plnkr.co/edit/VJKrDRMJY3Q73bsCgVwX?p=preview
我無法在Chrome或Firefox中打開演示程序 – charlietfl
我在本地系統中運行時出現錯誤。 –
但演示並不代表錯誤。如答案中所述,甚至沒有不正確的控制器。很難調試正在工作的東西。見[mcve]。在某處,你有一個不正確的注入類似於:'app.controller('A',function($ scope,prepareDtoFactory()){'...注意注入參數中的函數 – charlietfl