Reputation:
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('customersCtrl', function ($scope, $http) {
$scope.insadmin = function () {
$http.get('/csuv5.asmx/tadmin', {
params: {
auserid: $scope.userid,
bpass: $scope.pass,
cname: $scope.name,
ddesignation: $scope.designation,
eteam:$scope.team
}
})
.then(function (response) {
$scope.sonvinrpm = 'success';
// $scope.userid="",
// $scope.pass = "",
// $scope.name = "",
// $scope.designation = "",
//$scope.team = ""
$location.absUrl() = 'testangu.aspx';
});
}
});
</script>
this is my angularjs script of my application which is working fine but the problem starts with $location.absUrl() = 'testangu.aspx';
this line here i want to redirect the page to another page but it is not working $scope.sonvinrpm = 'success';
the success message is showing but the page is not redirecting to another page this is the first time i am trying this so guys please do help me out
Upvotes: 0
Views: 64
Reputation: 881
You can simply use windows location to meet your requirement
location.href = "testangu.aspx";
I hope it works for you
Upvotes: 0
Reputation: 105439
If you want to refresh the entire page and reset the state of your application you can use:
$window.location.reload();
This is a standard DOM method which you can access injecting the $window service.
If you want the success
message to be shown for some time before the page is reloaded, you can wrap the code above into timeout and wait some time:
var timeToWait = 3000; // 3 seconds
$timeout(function() {
$window.location.reload();
}, timeToWait);
Upvotes: 1
Reputation: 3780
The url()
in AngularJS is a getter/setter method. You can set it by passing the URL value as the method argument:
$location.url('testangu.aspx');
Upvotes: 0