Objective:
Angular get through the link form to access the page, to get the parameters in the URL, can not be routed through the way to get, using native JS or jquery, it is more troublesome, fortunately, angular has encapsulated the method to get the URL parameters, and only one line of code to fix, Simple rough, the way to win over traditional URLs to intercept matching strings.
var para= $location. $ $search ["Para"]
Other parameters in the URL are obtained:
//the URL with the # number, see? The URL of the number, see belowurl = http://qiaole.sinaapp.com? #name =CCCCCC$location. Absurl (); //http://qiaole.sinaapp.com? #name =CCCCCC$location. Host (); //qiaole.sinaapp.com$location. Port (); // the$location. Protocol (); //http$location. URL (); //? #name =CCCCCC //Get URL parameters$location. Search (). Name; //or$location. Search () [' Name ']; //Note: If this is the address: HTTP://QIAOLE.SINAAPP.COM?NAME=CCCCCC varSearchapp = Angular.module (' Searchapp '), []); Searchapp.config ([' $locationProvider ',function($locationProvider) {$locationProvider. Html5mode (true); }]); Searchapp.controller (' Mainctrl ', [' $scope ', ' $location ',function($scope, $location) {if($location. Search (). keyword) {$scope. Keyword=$location. Search (). keyword; } }]);
Get the URL parameter in Angularjs