ionic-framework: $ionicView.beforeEnter is not fired
after the update from ionic 1.3.0 to 1.3.1 the $ionicView.beforeEnter is not fired any more as before
I have this controller:
class MyCtrl {
static $inject = [
"$scope"
];
constructor(
private $scope
) {
$scope.$on("$ionicView.beforeEnter", (event, data) => {
this.activate();
});
}
}
in version 1.3.0 the activate() method is called as expected in version 1.3.1 the activate() method is not called
the fix is to roll back to version 1.3.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 23 (8 by maintainers)
Before ($ionicView.beforeEnter is not fired) :
After ($ionicView.beforeEnter is fired):
@danbucholtz is right, ensuring there is only 1 root element in your template fixes this issue.
I had this issue occur when I had the following:
Moving the
<script>block to inside the<ion-view>fixed it for me.Hi @asmund1,
When I use your Plunkr, I do see the issue. However, it is because your template is not a container. That’s an edge case so I’m not going to make a change right now to support that. If you change your template to the following, it works correctly.
@rxnh8255, @darthdie, Please help me out with what is unique with your apps. Can you make a plunkr or a codepen demonstrating the issue? I cannot recreate it presently. Please let me know. Thanks for the details @darthdie. Why is your stateValue null?
Please let me know and I’ll get it resolved.
Thanks, Dan
In my testing it appears this was broken in commit d63733350b73c0084f99fe285dda96f0204b2cd7
Specifically the following line returns null (thus it then has no scope to emit events to)
From further testing it appears it returns null because inside of
getScopeForElementThe condition
if ( stateValue === stateData.stateName )is false because stateValue is null. (At least in my particular case)In case anybody is interested (and/or needs these events to fire like myself) for now I’ve patched it simply by merging the original with the new (inside of the
emitfunction in “$ionicViewSwitcher”), i.e.