Comment rediriger vers une URL externe
génial
Lorsque vous essayez de rediriger vers une page externe en utilisant $window.location.href
, la page est simplement rafraîchissante et ne redirige pas vers l'URL attendue.
Gène Alaksandar Jesus
<html ng-app="myApp">
<head>
</head>
<body ng-controller="myCtrl">
<p> <a href="https://www.google.co.in/"><button>Click me to redirect from template</button></a></p>
<p ng-click="myFunction()"> <button>Click me to redirect from controller</button></p>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script>
var app = angular.module('myApp',[]);
app.controller('myCtrl',function($window,$scope){
$scope.myFunction = function(){
$window.location.href = 'http://www.google.com'; //You should have http here.
}
});
</script>
</body>
</html>
Cela fonctionne pour moi.