Saturday, 10 August 2013

angularJS directive, and exposing scope from inside?

angularJS directive, and exposing scope from inside?

OK I am defining a ng-click that retrives data from the currently clicked
elements scope, In my directive like so:
scope.dbclickalert = function () {
var getCheckInDate = this.cellData.date;
var formatcheckindate = new Date(getCheckInDate);
var checkingdates = scope.checkingdates;
var curr_datecell = formatcheckindate.getDate();
var padded_day = (curr_datecell < 10) ? '0' + curr_datecell :
curr_datecell;
var curr_monthcell = formatcheckindate.getMonth() + 1;
var padded_month = (curr_monthcell < 10) ? '0' + curr_monthcell :
curr_monthcell;
var curr_yearcell = formatcheckindate.getFullYear();
var date_stringcell = +padded_month + "/" + padded_day + "/" +
curr_yearcell;
var checkindatestrg = "checkindate";
var checkoutdatestrg = "checkoutdate";
console.log(arrayconstrct);
if (arrayconstrct.length >= 1) {
arrayconstrct.push(checkoutdatestrg);
arrayconstrct.push(date_stringcell);
el.addClass('checkoutDate');
console.log(arrayconstrct);
var $rows = $('.date-sheet-row');
var $class1 = $('.checkInDate');
var $class2 = $('.checkoutDate');
var $afterClass1 = $class1.nextAll('.date-cell');
var $beforeClass2 = $class2.prevAll('.date-cell');
var $class1Row = $class1.closest('.date-sheet-row');
var $class2Row = $class2.closest('.date-sheet-row');
var $rowsBetween = $class1Row.nextUntil($class2Row);
var $inBetweenRows = $rowsBetween.find('.date-cell');
var $allBetween =
$afterClass1.add($beforeClass2).add($inBetweenRows);
$allBetween.addClass('checkeddates');
var count = $allBetween.length;
alert(arrayconstrct);
$('.book_now').addClass('bookingset');
$(".date-cell").each(function removeclasses() {
$(this).removeClass('availforcheckout');
$(this).removeClass('true');
});
} else {
el.addClass('checkInDate');
$('#checkoutbar').addClass('datePickerchecout');
$(".date-cell.true").each(function removeclasses() {
$(this).addClass('availforcheckout');
});
arrayconstrct.push(checkindatestrg);
arrayconstrct.push(date_stringcell);
console.log(arrayconstrct + arrayconstrct.length);
}
return arrayconstrct;
};
fiddle How do I go about accessing this functions array from the global
controller? ok to add a little bit more context I am originally
conscruting the array in a service which i can access from the controller
no problems but it allways returns empty i'm guessing this is because the
diretive doesn't send the data back to the array..

No comments:

Post a Comment