Reputation: 61
i need help understanding why this angular ternary doesn't work right
ng-mouseleave="window.location.href.indexOf('sell') != -1 ? sellModal = true : newsletterModal = true"
I want to set either sellModal or newsletterModal to true based on the url, however only the if condition works correctly and if the user is on the sell page then sellModal pops up, if they are on another page the newsletterModal is not set to true and this doesn't work.
Upvotes: 1
Views: 296
Reputation: 9084
Do not overkill the html, just make a function
$scope.onLeave = function(){
if (window.location.href.indexOf('sell') != -1) {
$scope.sellModal = true;
} else {
$scope.newsletterModal = true;
}
}
And then in your html...
ng-mouseleave="onLeave"
Upvotes: 1