Angular page Jump Newsletters parameter _javascript skill

Source: Internet
Author: User

First, you need to have your rout configured, such as:

$stateProvider
. State (' FirstPage ', {
URL: '/page/firstpage ',
templateurl: ' page/views/firstpage.html ') ,
controller: ' Firstpagectrl '
//dependencies: [' Service/vipseachservice ']
})
. State (' Secpage ', {p arams:{' message ': null},
URL: '/page/secpage ',
templateurl: ' page/views/secpage.html ',
controller: ' Secpagectrl '
})

Note the params attribute in the second address message, which is the object you want to accept the parameter to, defined in key:value form.

In the jump page, two methods can be passed, one is written directly in the HTML

<a ui-sref= "Sec-page" > Jump second page </a>

At this point, the argument follows the page address.

<a ui-sref= "Sec-page ({Message:messageid})" > Jump second page </a>

The second is written in controller.

. Controller (' Firstpagectrl ', function ($scope, $state) {
$state. Go (' secpage ');});

The same parameters are written at the end of the address, in the form of an object

. Controller (' Firstpagectrl ', function ($scope, $state) {
$state. Go (' Secpage ', {message:messageid}); 
});

Pass the parameters of the past, need to be in the target page of the controller in the $stateparams receive, the change method needs to be injected in advance

. Controller (' Secpagectrl ', function ($scope, $state, $stateParams) {
var test= $stateParams. Message;
});

The above is a small set to introduce the angular page jump newsletters The question, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.