question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error when starting BlockUIService in ngOnInit

See original GitHub issue

I’m currently trying to upgrade my application to Angular 9 and when starting the ng-block-ui service in an ngOnInit hook i get this error in my console:

ng-block-ui: TypeError: Cannot convert undefined or null to object
    at Function.from (<anonymous>)
    at BlockUIDirective.push../node_modules/ng-block-ui/__ivy_ngcc__/fesm5/ng-block-ui.js.BlockUIDirective.isComponentInTemplate (ng-block-ui.js:836)
    at BlockUIDirective.push../node_modules/ng-block-ui/__ivy_ngcc__/fesm5/ng-block-ui.js.BlockUIDirective.ngOnInit (ng-block-ui.js:802)
    at callHook (core.js:2614)
    at callHooks (core.js:2584)
    at executeInitAndCheckHooks (core.js:2537)
    at selectIndexInternal (core.js:6141)
    at Module.ɵɵadvance (core.js:6114)
    at RootComponent_Template (root.component.html:54)
    at executeTemplate (core.js:7495)

BlockUIModule.forRoot() declared at top level module. The BlockUIDirective is used in my RootComponent.

Config:

  • Angular: 9.0.1
  • ng-block-ui: 3.0.0-beta.4

My suggestion is that this code:

private isComponentInTemplate(element: any): boolean {
    let { children } = element || [];
    children = Array.from(children).reverse();
    return children.some((el: any) => el.localName === 'block-ui');
  }

can be changed to

private isComponentInTemplate(element: any): boolean {
    let { children = [] } = element;
    children = Array.from(children).reverse();
    return children.some((el: any) => el.localName === 'block-ui');
  }

I did not wanted to do a pull request for one line change.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
kuuurt13commented, Feb 26, 2020

@JulienOuvrard not sure if you saw my comment above, 3.0.0-beta.6 has been released (npm i ng-block-ui@next)

0reactions
kuuurt13commented, Jun 26, 2020

Fixed by #113

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error when trying to subscribe to function in ngOnInit
In your component the expression vehicle.ContactInformation.name is not defined, because ContactInformation is undefined.
Read more >
Developing An Angular 2 Application With TypeScript
After compiling and launching the application, you can login with a username ... blockUIService, false)); } private handleError(error: any, ...
Read more >
ng-block-ui - npm
To start blocking your app, simply invoke the start method. This method also can take a custom message to display while blocking. Once...
Read more >
居家網紅推薦指南- $.blockui is not a function的推薦與評價 ...
$.blockui is not a function 在error when starting BlockUIService in ... The text was updated successfully, ... cannot use the block ui in...
Read more >
Angular Error: "No Provider for Module..." - Blog Post
The error "No Provider for Module" is a common mistake when first starting ... import { Component, OnInit, OnDestroy } from '@angular/core'; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found