Tag:java for Hash comment hash comm form using mil
below to get and modify the URL to ( http://172.16.0.88:8100/#/homePage?id=10&a=100 ) For example
"One" gets (does not modify the URL)
[JavaScript]View PlainCopy
- 1. Get the current full URL path
- var absurl = $location. Absurl ();
- http://172.16.0.88:8100/#/homePage?id=10&a=100
- 2. Gets the current URL path (the contents after the current url#, including parameters and hashes):
- var url = $location. URL ();
- //Result:/homepage?id=10&a=100
- //3. Gets the sub-path of the current URL (that is, the content after the current url#, excluding parameters)
- var pathurl = $location. Path ()
- Results:/homepage
- 4. Get the protocol for the current URL (e.g. Http,https)
- var protocol = $location. Protocol ();
- Result: http
- 5. Get Host Name
- var localhost = $location. Host ();
- Results: 172.16.0.88
- 6. Get the port of the current URL
- var port = $location. Port ();
- Results: 8100
- 7. Get the hash value of the current URL
- var hash = $location. Hash ()
- Results: http://172.16.088
- //8. To get the serialized JSON object for the parameters of the current URL
- var search = $location. Search ();
- //Result: {ID: "Ten", A: " +"}
"Two" Changes (URL related content)
[JavaScript]View PlainCopy
- 1 Modify the sub-path portion of the URL (that is, the contents after the current url#, excluding parameters):
- $location. URL ('/validation ');
- Results: Http://172.16.0.88:8100/#/validation
- //2 Modifying the hash value portion of a URL
- $location. Hash (' myhash3 ');
- Results: HTTP://172.16.0.88:8100/#/HOMEPAGE?ID=10&A=100#MYHASH3
- 3 Modify the parameter portion of the URL (the first parameter represents the property name of the URL parameter, the second parameter is the property value of the property name, and if it is an existing attribute name, the modification, if not an existing attribute, is added)
- $location. Search (' id ',' 111 ')
- Result (Modify parameter value): http://172.16.0.88:8100/#/homePage?id=111&a=100
- $location. Search (' IDs ',' 111 ')
- Result (new IDs parameter): http://172.16.0.88:8100/#/homePage?id=111&a=100&ids=111
- 4. Modify multiple parameters at once
- $location. Search ({id: ' + ',' a ':' "}")
- Results: HTTP://172.16.0.88:8100/#/HOMEPAGE?ID=55&A=66#MYHASH3
- //5. The first value represents the property name of the URL parameter, and if it is an existing property name, it is deleted if it is not an existing attribute.
- $location. Search (' age ',null)
 
" three "modify URL but do not deposit history
In the above method of modifying the URL, each time the URL will be stored in the history, you can use the Back button to return to the pre-modified URL, if you do not want this effect, but simply replace the current record, you can use the $location. Path ('/validation '). Replace ();
Angular gets and modifies the current page URL by injecting $location