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.