AngularJS nested functions in services and dependency injection?
Ok I have two modules which depend upon each other both modules have
services, directives, ctrl's etc, now my question is how do i get values
assigned in the nested function of the second module's service in the
controller of the first service, I have added the dependencies to the
first controller but i can't see to get at the nested functions variables
to then manipulate them in the ctrl of the first module here's the
code(considerably cut down):
angular.module("mainapp", [
"dateSheet",
"bookingApp"
]).controller("AppCtrl", [
"$scope",
"$attrs",
"Booking",
function (scope, source, attributes, AppDataLoader,
booking, Booking) {
//HERE I NEED TO BE ABLE TO DO SOMETHING LIKE THIS
var getdaiyrate = function(){
var dumpDailyRates =
scope.Booking.getalldates.getrates.dailyPrice
console.log(dumpDailyRates);
}
}
]);
angular.module("bookingApp", ["bookingApp.services",]);
angular.module("bookingApp.services").service("Booking", [
function(){
function getRate(source, dateSheet, dateSheetCtrl, expect,
$$childTail, appData) {
var dateValue = $("Date", source).text()
|| "";
if (!dateValue) {
return null;
}
var dailyPrice = $("DailyPrice",
source).text() || "";
var weeklyPrice = $("WeeklyPrice",
source).text() || "";
var monthlyPrice = $("MonthlyPrice",
source).text() || "";
var isAvailable = $("IsAvailable",
source).text() === "1";
var minimumStay = Number($("MinimumStay",
source).text());
if (isNaN(minimumStay)) {
minimumStay = DEFAULT_MINIMUM_STAY;
}
return {
date: new Date(dateValue),
dailyPrice: dailyPrice,
weeklyPrice: weeklyPrice,
monthlyPrice: monthlyPrice,
reserved: !isAvailable,
minimumStay: minimumStay
};
}
return {
getalldates: function(source, $scope){
return getRate(source, scope);
}
};
}
]);
The above doesn't work what am i doing wrong.... Could someone please send
me in the direction of a decent tutorial that deals with a end to end app
using various modules and dependencies?? Chris
No comments:
Post a Comment