Details about ui-router routing in AngularJS1.6 /#! ,

Source: Internet
Author: User

Details about ui-router routing in AngularJS1.6 /#! ,

AngularJS routing uses the # + flag to help us differentiate different logic pages and bind different pages to the corresponding controller. Therefore, after setting the routing rules, set the href route link for tag a on the html page to switch between different views. Before Angular1.6, href = "#..." or href = "#/..." are usually written, and the result is not reflected in Angular1.6.

The result shows the address bar of the browser. The default view link displays "#!". /... ", Yes, add more in the middle! .

After AngularJS is upgraded to version 1.6, a lot more /#! . So what are the changes made in 1.6? Can refer to this: https://github.com/angular/angular.js/commit/aa077e81129c740041438688dff2e8d20c3d7b52

Solution 1:

Therefore, add the href attribute value to the tag of the html page! .

<P> <a href = "#! /AddStudent "rel =" external nofollow "rel =" external nofollow "> Add students </a> </p> <a href = "#! /ViewStudents "rel =" external nofollow "rel =" external nofollow "> View students </a> </p>

Complete code:

<Html> 

Solution 2:

If you want to make the routing performance consistent with the previous version, you can do this:

mainApp.config(["$locationProvider","$routeProvider",function($locationProvider,$routeProvider){     $locationProvider.hashPrefix(''); }]); 
<P> <a href = "# addStudent" rel = "external nofollow" rel = "external nofollow"> Add students </a> </p> <a href = "# viewStudents" rel = "external nofollow" rel = "external nofollow"> View students </a> </p>

Complete code:

<Html> 

In this way, there will be no more visits from the browser! No.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.