Reputation: 230
I am getting error in firebug.
Error: [$injector:modulerr] Failed to instantiate module autoQuote due to: [$injector:pget] Provider 'function prepareDtoFactory()' must define $get factory method.
My code fo angular js controller is as below.
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;
}
created plunker with all files
Please help me to fix this error. http://plnkr.co/edit/VJKrDRMJY3Q73bsCgVwX?p=preview
Upvotes: 1
Views: 432
Reputation: 1350
The controller and factory functions with angular take two parameters: the name of the service or controller, and the function. Changing those to .controller('dtoController', dtoController) should help.
Upvotes: 1