I am creating a budget app with HTML,CSS and Javascript considering the module structure,closures and Immediately Invoked (IIFE) principles. I have divide module structure into UIController ,Appcontroller,BudgetController.
I have a getinput method in UI Controller which returns an object with the input values from front end and i am calling this getinput from app controller.But i am getting error under line getinput method .Is there any syantax error or i am doing something wrong.
Script.js
var budgetController=(function(){
//some code
})();
/*--------------------------------------------------------------*/
// UI Controller
var UIController=(function(){
return
{
getInput:function(){
return {
type: document.querySelector('.add__type').value,
description: document.querySelector('.add__description').value,
value: document.querySelector('.add__value').value
};
}
};
})();
/*--------------------------------------------------------------*/
// App controller
var controller=(function(budgetctrl,UIctrl)
{
var ctrlAddItem=function()
{
var result=UIctrl.getInput();
console.log(result);
// get the input data
// add the budget item to budget controller
// add the item to ui controller
// calculate the budget
// display the result
}
// Button click event
document.querySelector('.add__btn').addEventListener('click',ctrlAddItem);
//event key event
document.addEventListener('keypress',function(event)
{
if(event.keyCode===13 || event.which ===13)
{
ctrlAddItem();
}
});
})(budgetController, UIController)

