I have solved it that way and it works fine:

The only thing I have to complain is that the stateChange should be a 
function of the $stateProvider`s state function to have everything 
together... Maybe Router 2.0 ;-)

  $rootScope.$on('$stateChangeStart', function(ev, toState, toParams, 
fromState, fromParams) {
        if (toState.name === "projects.selected.dates.day") {

          ev.preventDefault();

          var currentDate = new Date();
          var currentYear = currentDate.getFullYear();
          var currentMonth = currentDate.getMonth() + 1;
          var currentDay = currentDate.getDate();

          // The first time the user opens a project the date data is null in 
the toParams
          if (!toParams.year && !toParams.month && !toParams.day) {
            toParams.year = currentYear;
            toParams.month = currentMonth;
            toParams.day = currentDay;
          }
          // When ALL of the toParams parameters equal ALL values of the year, 
month AND day
          // then the user has not manipulated the url explicitly and does  
whish to see the current date
          else if (toParams.year === currentYear && toParams.month === 
currentMonth && toParams.day === currentDay) {
             toParams.year = currentYear;
            toParams.month = currentMonth;
            toParams.day = currentDay;
          }

          $state.go(toState.name, toParams, {
            notify: false
          }).then(function() {
            $rootScope.$broadcast('$stateChangeSuccess', toState, toParams, 
fromState, fromParams);
          });
        }
      });
// Do the 'same' for the week state and month state..


Am Dienstag, 5. August 2014 04:24:43 UTC+2 schrieb Eric Eslinger:
>
> Hmm, that bug is interesting - I definitely had issues with suppressing 
> notify on $state.go in a $stateTransitionStart event, which I didn't quite 
> solve (I ended up approaching the problem from a different direction, the 
> auto-redirecting routes).
>
> e
>
>
> On Mon, Aug 4, 2014 at 12:20 PM, bastienneJS <[email protected] 
> <javascript:>> wrote:
>
>>
>>> You said:"... mainly because I like to have all the calls that would 
>>> influence routing decisions made in the appropriate config block, instead 
>>> of attached to $rootScope with listeners."
>>>
>>> Yes the same here. I do not like that a certain state change is handle 
>>> in a global run function and not the appropriate state definitions! Instead 
>>> I have to listen to the $rootScope, baaahhhhh !!!
>>>
>>
>>
>> I have just read this: https://github.com/angular-ui/ui-router/issues/178
>>
>> It seems when I am inside the stateChangeStart event and I want to do 
>> state.go('putTheSameStateHereWhereICameFrom', 'firstDayOfWeekParameter); 
>> then I run into problems that the ui is not updated...
>>
>> sheeezuz... I thought ui-router is out of beta stadium... 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "AngularJS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/angular.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to