0

I was implementing nested routing in my app, So I made nested routing module inside nested components then imports module and declare component

But getting error: Cannot read property 'form' of null.... I imported form module also.

Then I check PendingChangesGuard.canDeactivate (can-deactivate.guard.ts:17)

But getting error: Cannot read property 'form' of null.... I imported form module also.

Then I check PendingChangesGuard.canDeactivate (can-deactivate.guard.ts:17)

2
  • Can you show a component which is implementing the interface? Commented Apr 6, 2019 at 6:27
  • Reproduce the issue in stackblitz. Commented Apr 6, 2019 at 7:46

1 Answer 1

1

Defensive programming, you should check variable is null or undefined before using it.

import { isNullOrUndefined } from 'util';

if(!isNullOrUndefined(component) && component.form.dirty){
     // your code
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.