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

How to pass more attributes to BlockTemplateCmp

Open nepso opened this issue 5 years ago • 2 comments

when starting blockUi I can provide only message. Right now I created custom interface BlockTemplateConfig and I am "hijacking" the message to pass whole object like this: export class BlockTemplateCmp { @Input() message: BlockTemplateConfig; } this.blockUIElement.start({...} as BlockTemplateConfig);

but it would be nice to have in the start method some 3rd attribute like 'context' where anyone can pass any custom data for block template component.

nepso avatar Mar 20 '19 10:03 nepso

@nepso so it is possible pass multiple attributes if needed by using an object, which it looks like you are doing in your example. So correct me if I am wrong but your suggested change would be like so...

// Current:
this.blockUIElement.start({ 
  message: 'test message',
  foo: 'bar'
} as BlockTemplateConfig);

// Suggested:
this.blockUIElement.start('test message', { 
  foo: 'bar'
} as BlockTemplateConfig);

If that is the case, I'm having a hard time seeing too much value added by it being passed as a second argument. Is there any issues or edge cases that the current way isn't achieving?

kuuurt13 avatar Mar 24 '19 20:03 kuuurt13

@kuuurt13 I think that it would be the best to just rename 'message' to something like data/options/context, so it would be more clear that there can be any configuration for BlockTemplateCmp, because message implies some string message. But as it is breaking change I proposed to add a second argument.

Anyway no big deal, because I guess people are already using message as context and pass there whatever they need.

nepso avatar Mar 25 '19 13:03 nepso