ng-block-ui icon indicating copy to clipboard operation
ng-block-ui copied to clipboard

BlockUI directive not working in Angular 18

Open ShoulderMonkey opened this issue 1 year ago • 3 comments

I'm upgrading to angular 18 from angular 17 in one of my projects and i'm getting error where using

@BlockUI()blockUI!: NgBlockUI

gives error:

TypeError: Cannot read properties of undefined (reading 'start')

had to switch to using the BlockUIService instead and specifying name in selector like so:

`<block-ui [template]="foregroundSpinner" name="test" >

constructor( private blockUI: BlockUIService ){

  }

this.blockUI.start('test') `

ShoulderMonkey avatar Aug 29 '24 13:08 ShoulderMonkey

FWIW, I have the same problem in one Angular app, but not in another. I found that in the app where the problem occurs, the decorator assigns the BlockUI instance to the component's prototype but the component object has its own property with an "undefined" value. In the app where everything works, the BlockUI instance is still set into the prototype but the component object itself doesn't have the property and is getting the prototype value.

eheck-is avatar Sep 06 '24 16:09 eheck-is

... and a possible workaround for that is to set "useDefineForClassFields" to false in typescript options for the time being

eheck-is avatar Sep 09 '24 11:09 eheck-is

Hi! Any update on this? I'm facing the same error with the directive in Angular 18

carlosavila890 avatar Nov 18 '24 01:11 carlosavila890