igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

Injecting a Service into a Custom Summary class question

Open NickCook-StruMIS opened this issue 3 years ago • 3 comments

Hi,

My question is exactly the same as Issue already logged and closed: see issue: https://github.com/IgniteUI/igniteui-angular/issues/6484

  • igniteui-angular version: 12.2
  • browser: Chrome

Steps to reproduce

Following the same steps on the linked Issue: https://github.com/IgniteUI/igniteui-angular/issues/6484

Result

I have tried to download and run the linked solution from Issue #6484, however unable to compile because it uses an old version of node & non-sass but i did notice in your recommended solution that you are creating an instance of the service in the constructor which defeats the objective of dependency injection.

constructor(public summary: SummaryService ) { super(); this.summary = new SummaryService(); }

Expected result

Would it be possible to have a newer version of the recommended solution as attached to #6484 because so far i have been unable to inject anything into a custom summary that inherits IgxNumberSummaryOperand or IgxSummaryOperand

Thanks for your help.

NickCook-StruMIS avatar Mar 23 '22 15:03 NickCook-StruMIS

I think i know why this doesn't work as how i expect. Is it because IgxColumn.Summaries is being set to a a type not an object, so when you new up the classRef in set summaries method in igniteui-angular.js you don't know what objects need injecting. Please see code snippet below from igniteui-angular.js

/** * Sets the column summaries. * typescript * this.column.summaries = IgxNumberSummaryOperand; * * * @memberof IgxColumnComponent */ set summaries(classRef) { this._summaries = new classRef(); if (this.grid) { this.grid.summaryService.removeSummariesCachePerColumn(this.field); this.grid.summaryPipeTrigger++; this.grid.summaryService.resetSummaryHeight(); } }

Can you confirm please. It would help me to know if i am doing something wrong or I need to do this a different way. Thanks.

NickCook-StruMIS avatar Mar 24 '22 09:03 NickCook-StruMIS

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar May 25 '22 00:05 github-actions[bot]

Hello @NickCook-StruMIS , I have updated the sample from the previous issue, here you can see it. About your other comment .. yes you are correct the summaries properties are set to a class reference and we make an instance of it and according to the current implementation we can not know if there are any dependencies that need to be injected, so this sample is kind of workaround about that. Please check it and if you have any additional questions just let me know

ddincheva avatar Jul 18 '22 08:07 ddincheva

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Sep 20 '22 00:09 github-actions[bot]