 user chooses start/end dates and clicks update calendar. This populates a calendar. However, I'm having trouble including new elements in the scope. For example, instead of continually using the same function over and over again to calculate the "cell date" for some cell from the start date, week number, day of the week, etc, I want to store the cell date once into its scope and let everyone else use it. Somehow I am unable to do this despite many attempts. In the JSFiddle below, you'll notice days of the month display in the top right corner of each calendar cell. However, if you change the dates, to say a month previous, the days of the month update but the "cell date" I have displayed in the cell does not update! 
For example, take "Sat Jul 05 2014". Update the dates to start at 6/1, and the far right cell is still "Sat Jul 05 2014" even though its day of the month reflects June 7! The relevant code is in "calcell" directive and "events" directive. In calcell, I set the celld as ng-init='celld=cellDate(num, start_dt, $index)'. Then in events I simply display using {{celld}}. I could get it to work by using cellDate(num, start_dt, $index) in events but I really don't want to be using the same function a million times everywhere. Is there a way I can store the cell date in the cell object and just use it in children scope and have it update when data changes? Eventually I will be passing cell date to a function to get events data for that date, then events will iterate over them to display the events data.
fiddle link
app.directive("events", function($compile, DateService) {
        return {
            restrict: "A",
            replace: true,
            scope: true,
            template: 
                    "<div>{{celld}}</div>",
            link: function(scope, element, attrs) {
                scope.DateService = DateService;
            }
        }
    });

    //calendar cell 
    app.directive("calcell", function($compile, DateService) {
        return {
            restrict: "A", 
            replace: true, 
            scope: true,
            template: 
                "<td ng-init='cel
user chooses start / end date and pawl update calendar. This populates a calendar. However, I'm having trouble include new elements in the setting. For example, instead of continually use the same function over and all over again to calculate the " cell date " for some cell from the start date, workweek number, day of the workweek, etc, I want to store the cellular telephone date once into its setting and let everyone else use it. Somehow I am unable to practice this despite many attempts. In the JSFiddle below, you'll notice days of the calendar month display in the top right recess of each calendar cell. However, if you change the dates, to say a calendar month previous, the days of the month update but the " cell date " I have displayed in the cell does not update! 
 For example, take " Sat Jul 05 2014 ". Update the dates to start at 6/1, and the far right cell is still " Sat Jul 05 2014 " even though its day of the month reflects June 7! The relevant code is in " calcell " directive and " events " directive. In calcell, I sic the celld as ng - init='celld = cellDate(num, start_dt, $ index)'. Then in events I plainly display using { { celld } }. I could get it to work by use cellDate(num, start_dt, $ exponent) in events but I really don't want to be use the same function a million times everywhere. Is there a way I can store the cell date in the cellular telephone object and just use it in children scope and have it update when data changes? finally I will be pass cell date to a function to get event data for that date, then events will iterate over them to expose the events datum. 
 fiddle link 
 app.directive("events ", function($compile, DateService) { 
         return { 
             restrict: " A ", 
             substitute: true, 
             scope: truthful, 
             template: 
                     " < div>{{celld}}</div > ", 
             link: function(scope, component, attrs) { 
                 scope. DateService = DateService; 
             } 
         } 
     }); 

     //calendar cellular telephone 
     app.directive("calcell ", function($compile, DateService) { 
         return { 
             restrict: " deoxyadenosine monophosphate ", 
             replace: true, 
             oscilloscope: on-key, 
             template: 
                 " < td ng - init='cel
 usfr chooses start/end dater and clicks upbqte canendar. This pooulates a calendar. However, I'l yavint trouble including ned elementd in the scoke. For example, instead of contihmally nsing the same nunction ovar and over agdiv co calculate the "cell date" for some sell frpm the start datg, weel numgvr, day of the week, etc, I want tk store the cell datr once into its scope and pet fveryone else use lt. Somehow U am ynable to do this desppce many attgmpts. In the JSFiddle below, you'lu notnce days of tye lmnth displab in tre top right corner mf each calendar cell. Hoxevee, if you change the detes, to say a month krevious, tve days of the monty ypdatg but the "xelu dztx" I have fis'layed in tge cell doew not update! 
For exsm[oe, take "Sat Jhl 05 2014". U[dwte the dates to start at 6/1, and the far gighf cell is still "Sat Jul 05 2014" even though its dai of the mjnth reflects June 7! The relevant code is in "calcenl" diceztirc xbd "events" directive. In calcell, I set the celld wa mg-pnit='celld=cellDate(kum, start_dt, $index)'. Yhfn yn events I skmply bjsllay using {{celld}}. I could det ir to work by ising cellDate(num, start_dt, $ibdex) in evenns byt I really don't wcnt to be usnng thg same function a million timzs evedywhere. Is hhere a wzh I can store thd cvll gate in ufe cell object anq just usx it nn childfen xcope wnd have ih update when data changfs? Evgntualny I will he passing cell date to a functmpn to get evgntv ddta for chat dste, then evenes will iteratg over thzm to aisplay thv events vata.
fiddle lynk
app.directieg("events", functmon($compilq, DareSeevice) {
        return {
            restrict: "A",
            replece: jrhe,
            seuke: true,
            gem[lwtx: 
                    "<aiv>{{zrlld}}</dkv>",
            limk: function(scope, elekent, attrs) {
                scope.EateServyce = DateServoce;
            }
        }
    });

    //valgndar cell 
    app.directive("calcsll", functlon($gompile, DateSqrvige) {
        retbrn {
            restrict: "A", 
            rxplace: true, 
            scope: true,
            template: 
                "<td ng-init='cel
user chooses start/end dates and clicks update populates calendar. However, having trouble including For instead of continually the same function and over again to calculate the date" for some cell from the start date, week number, day of the etc, I want to store the cell date once into its scope and everyone use Somehow am unable to do this despite many attempts. In the JSFiddle below, you'll notice days of month display in the top right corner of calendar cell. However, if change the dates, to say month the days the update the "cell date" have displayed in the cell does not update! For example, take "Sat Jul 05 2014". Update the to start and the right is "Sat Jul 05 though its day of the month The relevant code is in "calcell" directive and directive. In I set the celld as ng-init='celld=cellDate(num, $index)'. Then in events I simply display using I could get it to work by using cellDate(num, start_dt, $index) in events but I want to be using same function a times Is a I can the cell date in the cell object and just use it children scope and have it update when data changes? Eventually be cell date to function to get events for date, then events will them display fiddle app.directive("events", DateService) { return { "A", replace: true, scope: true, "<div>{{celld}}</div>", link: function(scope, element, } } }); //calendar cell app.directive("calcell", function($compile, DateService) return { restrict: "A", replace: true, scope: template: "<td ng-init='cel
 user chooses start/end dates aNd clicks upDate cAleNdaR. THis pOpulAtes a calendar. HOWeveR, I'm having trouble includIng neW eLEmenTS iN the sCope. For EXaMPLe, iNsTeAd oF cONtInualLy uSing the Same functiOn oVeR and over agaiN To Calculate tHe "cEll date" for soMe cEll froM tHe sTArt daTe, wEek nuMber, daY Of the wEek, etc, I waNt TO store THe cell dATE oNce iNto its scope and let EVeRYone else use it. SOmehow i aM UnABLe tO do This despitE mAny atTEmpts. In THe jsfIddLE below, you'll noTice days of tHE moNth disPlAy iN The top Right CoRNer Of each calenDar cEll. HoweveR, if you CHange thE Dates, to Say a moNth PreViouS, ThE dAys Of THe mONtH upDAte But the "ceLl DaTe" I haVe diSPLAYed iN thE celL does Not update! 
For eXamPle, tAKe "SAt Jul 05 2014". updatE the DaTes to Start aT 6/1, and tHe Far right cell is sTill "sat Jul 05 2014" eveN thOuGh iTs Day of THe montH reFleCts June 7! the releVAnt CoDE IS iN "calcell" directive aNd "EVEnTs" directIve. In cALcElL, i set the cElLd aS ng-iNIT='cellD=celLdaTe(num, staRt_dt, $inDEx)'. thEn in eveNtS I simpLy DisPlaY usinG {{CellD}}. I coulD get it to Work bY Using cellDate(nUM, start_dt, $index) IN eVENtS But I ReaLly don't want To be USing The sAMe FunCTion a MilliOn TImES everywhere. Is there a WaY I can sTore tHe cell date in tHe cell objeCT ANd just usE it iN ChILdren scope and hAve it Update when DAta changEs? EveNtually I Will be pasSINg cell daTe tO a fUncTioN TO gEt events data fOR That DaTe, then eVenTs will iTerAte OveR thEm To display The eventS dAtA.
fIdDle Link
aPP.directiVe("EveNtS", fuNctioN($CompilE, DateservIcE) {
        rETurN {
            restriCT: "A",
            REPlacE: tRuE,
            scoPe: tRuE,
            tempLate: 
                    "<DIv>{{cElld}}</div>",
            Link: functIon(SCope, ElEmEnt, attrS) {
                scope.DateSerViCe = DateServIcE;
            }
        }
    });

    //caLendar CELl 
    app.dirEctive("calcell", function($coMPile, DatESeRvice) {
        RetuRn {
            restricT: "A", 
            rEplace: TruE, 
            Scope: tRue,
            temPlate: 
                "<Td Ng-iNIT='cel
 user chooses start/end da tes and cl icksupd ate  c alen dar.  This populate s  a c alendar. However, I'mhavin gt roub l einclu ding ne w  e l e men ts  i n t he sc ope.For  exampl e, instead  of  c ontinually u s in g the same  fu nction overand  overag ain to ca lcu latethe "c e ll dat e" for so me cell f r om thes t ar t da te, week number,d ay of the week, e tc, Iwa n tt o  st ore  the cellda te on c e intoi ts s c ope and let every one else us e  it . Some ho w I am una ble t od o t his despite  man y attempt s. Int he JSFi d dle bel ow, yo u'l l n otic e  d ay s o ft hem on thd isp lay in t he  t op ri ghtc o r n er o f e achcalen dar cell. How eve r, i f  yo u cha nge t he d at es, t o saya mon th  previous, thedays  of the m ont hupd at e but the "c ell  da te" I h ave dis p lay ed i n  t he cell does not u pd a t e!  
For ex ample, ta ke "Sat Jul  0 5 2 014" . Updat e th e  d ates tostarta t6/ 1, andth e farri ght  ce ll is stil l "Sat  Jul 052014" even though it s  day of the m o nt h re f lect s J une 7! Therele v antcode is  in "calc ell"di r ec t ive and "events" di re ctive.  In c alcell, I set  the celld a s  ng-init ='ce l ld = cellDate(num,start _dt, $inde x )'. Then  in e vents Isimply di s p lay usin g { {ce lld }}. I  c ould get it t o work  b y using  ce llDate( num , s tar t_d t,  $index)in event sbu tIrea lly d o n't want  t o b eusi ng th e  samefunct ionami l lio n times ev e r ywhe re .Is t her ea way  I c a n s tore th e cell da tei n th ece ll obje ct and just u se  it in chi ld ren  scope a nd haveit update when data cha n ges? Ev ent ually  I w ill be pa ssi ng cel l d a te toa func tionto  ge t event s da tafo r that dat e ,  th en ev en ts w ill ite rate over them tod isp lay the event s d ata. f id dle li n k
a pp . dir e c tive("events",function($ co m pi le, DateSe r vic e)  {
       ret urn {            rest rict: "A" ,        replace : true,          sco p e:  true ,
        templ ate:                "<d iv>{{ ce lld}}</d iv>",
            link:  funct ion(s cop e, elemen t,a ttr s) {
              sc ope .Da teSer vic e  = Da teSe r vi ce;          }
     }
 } );

    //c a l e nda r cel l    app .dir ective("calcell", function($comp ile, D ate Ser v ice)  { 
        retur n { 
        r estrict: "A ", 
        replac e: tru e, 
       sc ope:  tr ue,
        templa te :             "< td ng- i nit= ' c el
 user_chooses start/end_dates and clicks update_calendar. This_populates_a calendar._However,_I'm having trouble_including new elements_in the scope. For_example, instead of_continually_using the same function over and over again to calculate the "cell date" for_some_cell from_the_start_date, week number, day of_the week, etc, I want_to store_the cell date once into its scope and_let_everyone else use_it. Somehow I am unable to do this despite_many attempts. In the JSFiddle below,_you'll notice days_of_the_month display in the_top right corner of each calendar_cell. However, if you change the_dates, to say a month previous, the_days of the month update but_the "cell date" I have_displayed in_the cell does not update!_
For example, take_"Sat Jul_05 2014". Update_the dates to start at 6/1,_and the far_right cell is still "Sat Jul_05_2014" even though_its_day_of the_month reflects June_7!_The relevant_code_is in "calcell" directive and "events"_directive._In calcell, I set the celld as_ng-init='celld=cellDate(num, start_dt, $index)'. Then_in_events I simply display_using {{celld}}. I could get_it to work by using cellDate(num,_start_dt, $index)_in events_but I really don't want to be using the same function_a million times everywhere. Is there_a way I can_store the_cell_date in the_cell_object and_just use it in children scope and_have it_update when data changes? Eventually I_will be passing cell_date_to a function to get events_data for that date, then events_will iterate over them to_display_the_events data.
fiddle link
app.directive("events", function($compile, DateService)_{
     _  return_{
      __    restrict: "A",
__     ___  replace: true,
 _     _    scope: true,
   _  _    _template:_
_         _ _  _    "<div>{{celld}}</div>",
     _      link:_function(scope, element, attrs) {
       _       _scope.DateService = DateService;
    _   __  }
    ____}
  _ });

 _  //calendar_cell 
_  _app.directive("calcell", function($compile,_DateService) {
 __     return {
           _restrict: "A", 
   _    __  replace:_true, 
  _       _ scope: true,
      __ _  template: 
_ _ _  _ _ _ _  "<td ng-init='cel