Friendly URLs in Angularjs: Remove the pits that are encountered in the URL

Source: Internet
Author: User

Angularjs for a period of time, should the project needs, to remove the URL of those #, search the online method is very simple

Http://developer.51cto.com/art/201406/443898.htm

It is easy to get a clean URL and to remove the pound sign from the URL.

Do two things on the line.

    1. configuration $locationProvider

    2. Set the start path of our relative connection

  Monitorapp.config ([' $stateProvider ', ' $urlRouterProvider ', ' $locationProvider ',    function ($stateProvider, $ Urlrouterprovider, $locationProvider) {        $urlRouterProvider. Otherwise ('/main/service ');        $stateProvider            . State (' main ', {                URL: '/main/:type ',                templateurl: ' pages/main.html ',                controller: ' Maincontroller '            })            . State (' monitor ', {                URL: '/monitor/:template ',                templateurl: ' pages/ Monitor.html ',                controller: ' Monitorcontroller '            )        $locationProvider. Html5mode (True);    }])

In order to use relative links throughout the application, you will need to set a <set> in the

  
 
  1. < Span style= "margin:0px; padding:0px; Border:none; Background-color:inherit "><!doctype html > &NBSP;
  2. < html > &NBSP;
  3. < Head >  
  4.     <Meta CharSet="Utf-8"> 
  5.     <Base href="/"> 
  6. </ Head >  
two issues encountered during the setup process

1. When the base href is not configured on the home page, access to/main/service cannot be controlled by Maincontroller.

2. After the configuration is complete, all the a tags on the page are set to href= #的链接都会往默认的首页跳转, because I configured the

<span style= "FONT-SIZE:18PX;" >   $urlRouterProvider. Otherwise ('/main/service ');</span>
<span style= "FONT-SIZE:18PX;" >   in order to solve this problem, I have just started to remove the attributes of href=#, and then think of such a click when the mouse gesture is not quite right, although can be resolved with CSS, but the limit is too dead </span>
<span style= "FONT-SIZE:18PX;" >   later accidentally changed the version of Angularjs solved the problem, the original issue of the version is v1.2.5, replaced by 1.3.9</span>



Friendly URLs in Angularjs: Remove the pits that are encountered in the URL

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.