Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use $transitions?

Currently, I'm using:

  • "angular-ui-router": "^0.4.2"
  • "angular": "^1.6.3"
  • "webpack": "^2.4.1"

I am aware of my current implementation might be deprecated, just looking for the implementation(an example or documentation) of the new method. Any help is greatly appreciated, thanks in advance!

Current implementation:

'use strict';

module.exports = angular
  .module('common', [
    'ui.router',
    'angular-loading-bar',
    require('./header').name,
    require('./sideBar').name,
    require('./footer').name
  ])
  .run(function($transitions, cfpLoadingBar) {
    $transitions.onStart({}, cfpLoadingBar.start);
    $transitions.onSuccess({}, cfpLoadingBar.complete);
  });

Current error:

Uncaught Error: [$injector:unpr] Unknown provider: $transitionsProvider <- $transitions

like image 861
alphapilgrim Avatar asked May 02 '17 20:05

alphapilgrim


People also ask

What is a good transition sentence?

What are the components of good transition sentences? They make an explicit connection between ideas, sentences, and paragraphs. Good transitions use specific words. Try to avoid using pronouns like “this” to refer to an entire idea because it is not always clear who or what “this” refers to.

What is the best way to effectively use transitions is to?

As you write, use transition words to help you organize information effectively. Transitions can help signal connections between a main idea and supporting ideas. They can also signify comparisons or contrasts, and transition words are an excellent way to introduce and identify related concepts.

What are some examples of transitions?

Examples of Transitions: On the contrary, contrarily, notwithstanding, but, however, nevertheless, in spite of, in contrast, yet, on one hand, on the other hand, rather, or, nor, conversely, at the same time, while this may be true.


1 Answers

In new versions (>=1.0.0) the $state change events are deprecated, and now you have to use the $transitions instead...

$transitions for new versions (>= 1.0.0) (PLUNKER DEMO)

MyCtrl.$inject = ['$transitions'];

function MyCtrl($transitions) {
    $transitions.onSuccess({}, function($transition){
        console.log($transition.$from());
        console.log($transition.$to());
        console.log($transition.params());
    });
}

Available events ordered by invocation:

$transitions.onStart({}, function($transition){...});

$transitions.onExit({exiting: "stateName"}, function($transition){...});

$transitions.onRetain({}, function($transition){...});

$transitions.onEnter({entering: "stateName"}, function($transition){...});

$transitions.onFinish({}, function($transition){...});

$transitions.onSuccess({}, function($transition){...});

Too see each event method in detail: $transition service docs
Also some examples: Migrations examples from 0.4.2 to 1.0.0 in official docs


$state changes events for old versions (<= 0.4.2) (PLUNKER DEMO):

MyCtrl.$inject = ['$scope'];

function MyCtrl($scope) {
    $scope.$on('$stateChangeStart', 
        function(event, toState, toParams, fromState, fromParams, options) {...});

    $scope.$on('$stateChangeSuccess', 
        function(event, toState, toParams, fromState, fromParams, options){...});
}

Check angular-ui-router docs for more $state change events

like image 112
The.Bear Avatar answered Sep 29 '22 19:09

The.Bear