我在萤火虫中遇到错误。
错误:[$ injector:modulerr]由于以下原因无法实例化模块autoQuote: [$ injector:pget] Provider' function prepareDtoFactory()'必须定义$ get factory方法。
我的角度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
答案 0 :(得分:1)
带角度的控制器和工厂功能有两个参数:服务名称或控制器名称和功能。将它们更改为.controller(' dtoController',dtoController)应该会有所帮助。