<! DOCTYPE html>The above shows the basic usage of Ui-router
EventAs with Ngroute, the Angular-route service initiates certain events in different state life cycle lifecycle. Listening to $scope objects captures these events and then takes a different response or action. The following events will be triggered on $rootscope, so these events can be heard on any $scope object.
Status Change Events$scope. $on (' $stateChangeStart ', function (evt, tostate, Toparams, FromState, Fromparams), {//If you need to block the completion of an event Evt.preventdefault ();});
The events that can be triggered include:
Statechangestart
Triggered when the state change is started
$stateChangeSuccess
Triggered when the status change is successful
$stateChangeError
When a state change encounters an error, the error is usually that the target cannot be loaded, the pre-loaded data cannot be loaded, and so on.
View Loading EventsView Loading phase Ui-router also provides some events
$viewContentLoading
Triggered when the view is being loaded and before the DOM is rendered.
$scope. $on (' $viewContentLoading ', function (event, viewconfig) {//Get parameters for any view setting, and a special property: Viewconfig.targetview}); $ viewcontentloaded
Triggered when the view is loaded and the DOM has been rendered.
In the event, say 2 more sentences:
In the source code of 3151 lines, defines the route jump method.
$state. Transitionto = function Transitionto (to, Toparams, options) {
In the method, Ui-router calls $rootscope. $broadcast and broadcasts the event.
While $broadcast, $emit and $on are not the focus of this section, here is a brief introduction:
$broadcast: Triggers an event to the current and child scopes.
$emit: Triggers an event to the current and parent scope
$on: Defining events in the current scope
Similarly, in Ngroute, some events have been defined
such as: $routeChangeStart, $routeChangeSuccess, $routeChangeError
Deep routing (nested routines) <! DOCTYPE html>Refer to:
Ui-router GitHub (Https://github.com/angular-ui/ui-router/wiki)
This address: http://www.cnblogs.com/neverc/p/5907693.html
[AngularJS] Angularjs Series (2) routing of intermediate articles