1 Ui-sref, $state. The difference between go
ui-sref
Generally used in<a>...</a>;
<ui-sref= "message-list"> Message Center </a>
$state.go(‘someState‘)
Generally used in the controller inside;
function ($scope, $state) { $state. Go (' login ');});
These two are essentially the same thing, we look at the source code of UI-SREF:
... element.bind (function(e) { var button = E.which | | E.button; if ( ! (Button > 1 | | e.ctrlkey | | e.metakey | | e.shiftkey | | element.attr (' target '))) { var transition = $timeout (function() { /// here we Call $state. Go inside of Ui-sref $state. Go (ref.state, params, options); });
Ui-sref Last Call or $state.go () method
2 How to pass parameters
First, you define the accepted parameters on the target page:
Pass the argument,
Ui-sref:
$state. Go:
Receive parameters,
Inject $stateparams into the controller of the target page, and then "$stateParams. Parameter name" gets
In Angularjs Ui-sref and $state. Go how to pass parameters