In Angularjs Ui-sref and $state. Go how to pass parameters

Source: Internet
Author: User

1 Ui-sref, $state. The difference between go

ui-srefGenerally 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.