3

I'm getting Type Error when trying to destroy the viewer in Angular2.

for that I tried this code,

ngOnDestroy() {
        if (this.viewer && this.viewer.running) {
            this.viewer.tearDown();
            this.viewer.finish();
            this.viewer = null;
        }
    }

But getting Error like below:

TypeError: Cannot read property 'updateMaterials' of null
    at tick (viewer3D.js:27154)
    at animloop (viewer3D.js:27631)
    at ZoneDelegate.invokeTask (zone.js:356)
    at Object.onInvokeTask (node_modules/@angular/core//bundles/core.umd.js:9091)
    at ZoneDelegate.invokeTask (zone.js:355)
    at Zone.runTask (zone.js:256)
    at ZoneTask.invoke (zone.js:423)

How can I fix this issue using Angular2?

2
  • What is this.viewer ? Commented Jul 17, 2018 at 10:18
  • "this.viewer" is the instance of forge viewer. Commented Jul 18, 2018 at 5:25

1 Answer 1

0

Please check this answer. Additionally, you may also need to .impl.unloadCurrentModel()

Sign up to request clarification or add additional context in comments.

1 Comment

@RuhamaDavid I tried your original code, and works fine. I'm guessing your Angular code still trying to access the Viewer and causing this error (updateMaterials occurs with the render). The other answer suggests to keep the Viewer running when you navigate between states/pages on your SPA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.