Reputation: 31
I have the following code in my js file.
$scope.addLookupAction = function () {
$("#importForm").attr("action", 'xyz.com');
success:function(response) {
$log.info("Redirecting to lookup home page");
window.location.href='abc.com';
}
};
I am trying to redirect the application to a new page(abc.com) on receiving a good http response(200) from 'xyz.com'. Any pointers on why this does not work? I have a bit of angularjs and jquery together which makes it even more convoluted...
Also, this is my first post on stack overflow... So Hello everyone !!! :)
Upvotes: 1
Views: 1152
Reputation: 1412
You can try this working for me..
e.preventDefault();
$http.post('xyz.com').then(function () {
window.location = jQuery('.btn').attr('href');
});
Upvotes: 0
Reputation: 256
Inject $location
to your controller:
$location.path('http://exmaple.com').replace()
Upvotes: 0
Reputation: 542
Is the function called when you click a button?
First you need to inject the $location and $http.
$scope.addLookupAction = function (e) {
e.preventDefault();
$http.post('xyz.com').then(function () {
$location.href = 'abc.com';
});
};
Upvotes: 1
Reputation: 1488
You don't need the href
, but should add http://
;
$scope.addLookupAction = function () {
$("#importForm").attr("action", 'xyz.com');
success:function(response) {
$log.info("Redirecting to lookup home page");
window.location.='http://example.com';
}
};
Upvotes: 0