Reputation: 1910
I have one below link
<a ng-click="logout()"><i class="fa fa-sign-out" name="sign-out"></i> Logout</a>
I want that when I click on this link first they called their logout()
function then they will redirect to the below page
https://demo.testlab.local/
The problem is that client don't want to change their code for logout() method. But I can ReWrite anything on this link code only <a ng-click="logout()"><i class="fa fa-sign-out" name="sign-out"></i> Logout</a>
.
So Is their any solution for this.
Upvotes: 0
Views: 393
Reputation:
You can try this, but it's really bad:
<a ng-click="logout()" onclick="setTimeout(function () { console.log('changing location'); }, 1000);">Logout</a>
Just insert the code you want to run in place of console.log('changing location');
Edit: What you actually need is this:
<a ng-click="logout()" onclick="setTimeout(function () { window.location = 'https://demo.testlab.local/'; }, 1000);">Logout</a>
Upvotes: 0
Reputation: 79
You can use button tag inside a form, When button submits you can redirect to the link
<form action="https://demo.testlab.local/">
<input type="submit" value="Logout" onclick="logout()"/>
</form>
Upvotes: 0
Reputation: 62
Use below code:
<a ng-click="logout()" ng-href="https://demo.testlab.local/"><i class="fa fa-sign-out" name="sign-out"></i> Logout</a>
Hope this will work.
Upvotes: 1
Reputation: 5957
Assuming they won't change logout(), even to add in an argument to pass to it, and assuming that you want the same functionality to happen that is in logout(), the best thing is to make a new method and then call it after logout:
<a ng-click="logout(); newLogout()"></a>
And the method then is straightforward:
newLogout() {
this.$state.go(); // Using ui-router to move
this.window.location = ""; // Using plain javascript
}
You did mention that you can "rewrite anything on the link only" so perhaps you can't even change the controller?
Upvotes: 0