Angularjs get current url
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope,$location) { $scope.url = ''; $scope.currentUrl = function() { $scope.url = $location.absUrl(); // will change the current url to www.example.com/User/98 }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <p>Current Url = {{url}}</p> <input type="button" value="Get Current Url" ng-click="currentUrl()"> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope,$location) { $scope.url = ''; $scope.currentUrl = function() { $scope.url = $location.absUrl(); // will change the current url to www.example.com/User/98 }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <p>Current Url = {{url}}</p> <input type="button" value="Get Current Url" ng-click="currentUrl()"> </div> </body> </html>
Copyrights@tutorialsplane.com