ANGULARJS use controller to complete URL jump _angularjs

Source: Internet
Author: User

Examples of specific wording:

1.js defines a controller

function Myctrl ($scope, $location) {

  $scope. Jumptourl = function (path) {

    //todo:add code here

  };

}

2.html Inside Application Controller

<div ng-controller= ' Myctrl ' >

  <button ng-click= "Jumptourl ('/signin ')" >signin</button>

</div>

3.controller inside the TODO position fill in

$location. Path (path);

Then you can run it and see the effect.

Suppose the URL of the current page is: Http://127.0.0.1:8080/#/home

$location. Path (path); After execution, it jumps to http://127.0.0.1:8080/#/signin.

If you find that the page does not jump normal, you can $location.path(path); add a sentence in the following

var cururl = $location. Absurl (); Use to display URL full path

When you debug the trace page to see how much the Cururl value becomes, you can probably guess what the problem is.

Well, the above is in ANGULARJS use controller complete URL jump all the content, I hope this article for everyone to learn Angularjs help.

Related Article

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.