-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipes break when used in a ng-switch-default #5169
Comments
Same kind of issue (exactly the same callstack) if having an expression with an optional pipe, like this: |
I'm seeing the same exception reported by Xesued when I use a pipe inside of an ng-switch-default. I'm developing with angular 2.0.0-alpha.46 using chrome 47.0.2526.73 on a windows 10 machine. His plunker reproduces the error perfectly. |
+1 |
+1 same as Xesued |
+1 it is still there *beta.1 |
The issue also occurs with builtin pipes like the JSON pipe. Here's a plnkr from me for reproduction: |
+1 |
1 similar comment
+1 |
I simplified @Xesued's reproduction -- no custom pipe appears needed, just ensure ngFor keeps an unused branch so it tries to destroy a pipe that didn't get initialized. So the crash occurs here, due to
(For debugging I also tried to add a print statement in the parent stack level; here selectedPipe turned out as
I'm having trouble locally running the tests to verify this null check fixes the issue without messing up other things though; perhaps someone else would be able to try that... Edit: to clarify, I haven't verified if suppressing the error makes things work as desired; on my own code I still had an unrelated error I was already getting on other code as well, while with Plunker I'm not sure I can just alter the ng2 code like this, so I haven't actually seen the result. |
Having found a workaround for that issue now, I'm now able to confirm that the above check does indeed appear to address this issue. I wouldn't know what the right module for this should be, but I believe a test for the above fix could potentially look as follows.
... I'd appreciate further help though. |
+1 |
+1 |
+1 Confirming this issue. |
+1 |
suffering this bug? import this before you import angular stuff:
Obviously this is the hack from above, just packaged so that you can apply it without hacking into angular's files. |
+1 same with default router :( |
@laurelnaiad Tried your work around but could not get it to work. Also tried in bootstrap.ts with format: register in my system-config.js declare var System: {
register: Function
};
System.register("angular2/src/core/change_detection/pipe_lifecycle_reflector", [], true, function(require, exports, module) {
exports.implementsOnDestroy = (pipe) => pipe ? pipe.constructor.prototype.ngOnDestroy : false
}); |
@laurelnaiad Figured it out <script src="node_modules/systemjs/dist/system.src.js"></script>
<script>
System.register("angular2/src/core/change_detection/pipe_lifecycle_reflector", [], true, function(require, exports, module) {
exports.implementsOnDestroy = function(pipe) { return pipe ? pipe.constructor.prototype.ngOnDestroy : false };
});
</script> This did it for me. |
The file in question no longer exists in RC. Is this issue still relevant there? I failed to reproduce. |
Can no longer reproduce: https://plnkr.co/edit/E662nxksiK4z10gJAv7y?p=preview |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When using a custom pipe inside of an
ng-switch-default
the pipe breaks with the exception:Here is a plunker: http://plnkr.co/edit/PSRVVPtbl6MzRzNPzc2b?p=preview
When I remove the
ng-switch-default
template, I don't get the error.Using Chrome 46 on Mac.
The text was updated successfully, but these errors were encountered: