Angular-gridster2: cannot call service inside gridster item callback functions (itemResize,etc)

Created on 24 Aug 2017  路  12Comments  路  Source: tiberiuzuld/angular-gridster2

I am calling a service method from itemResize event but it is not working on aot build.
Trying to execute a method which updates the updated item information.

Getting below error in aot build, dashboardItemService is the service that we created

image

question

Most helpful comment

Try this.changed.bind(this)

All 12 comments

Hi @jtushar53
If You call from this is wrong this inside the callback is the gridster. You need to make an outside variable for this or to bind this on callback.

Let me know if this fixed your problem.
Thanks

@tiberiuzuld is right, i solved it with an Output() event syntax and it work like a charm! 馃帀

Another question:
Is it possible to display the hover drop area with an dashed frame? Like drag n drop a gridsterItem?

Hi @WhatzzUp ,
Yes, but tried that when I implement drag and drop and was a bit laggy and didn't liked that.
Will try to implement it again maybe will find a better way.

Thanks

Hai @tiberiuzuld yeah, i tried it yesterday and it was ... very ... very laggy.
Nevertheless good job! angular-gridster2 works like a charm!

made it work using Output,

Thanks @tiberiuzuld for angular-gridster2

and thanks @WhatzzUp for pointing out @Output

Could someone please post the working solution using Output?

@ndunas and for others to refer to:

private static changed: Subject<string> = new Subject<string>();

Have the above in your component or service and call next on it when itemResize or itemChanged callback or executed, then subscribe to the subject to do what you want

@jtushar53, @srivathsah, @tiberiuzuld. can you guys help me to understand this solution?

i declared two @Outputs:

image

then i set it in the template:

image

create the funtions:
image

and wait for it...... nothing happens! :/

Hi @the80 ,
I removed the @Output options from gridster-item in 4.3 forgot to remove them from Readme.md
Sorry about that but there where some memory leaks with them.

You need to use the options callbacks itemChangeCallback, itemResizeCallback.

Let me know if this will be ok for you.

Thanks

Thanks for the information @tiberiuzuld

But I m facing the same problem as @jtushar53 posted:

image

my function:
image

Anything i use is undefined, as you said above, anything inside options is gridster...
image

Try this.changed.bind(this)

@tiberiuzuld it works!

Thank you very much.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CollinGraf314 picture CollinGraf314  路  3Comments

ddegasperi picture ddegasperi  路  4Comments

tiberiuzuld picture tiberiuzuld  路  3Comments

leandro-ali-elel picture leandro-ali-elel  路  4Comments

MaiGhoneem picture MaiGhoneem  路  4Comments