kevcjones / ngx-simple-modal

A simple unopinionated framework to implement simple modal based behaviour in angular (v2+) projects.
MIT License
52 stars 28 forks source link

changing global default options #32

Closed Tahiche closed 6 years ago

Tahiche commented 6 years ago

Hi, I want to have some global options for all modals, for example "closeOnEscape: true, closeOnClickOutside: true,". Don´t want to specify that on every .addModal() call, it seems redundant. I can´t see an obvious way to do this. These default options seem to be set in SimpleModalHolderComponent, so it looks like they can´t be overriden at extending component either.

....
import { defaultModalOptions, SimpleModalOptions } from './simple-modal-options';
....

// assign options refs
    _component.options = options = Object.assign({}, defaultModalOptions, options);
kevcjones-archived commented 6 years ago

Seems like a reasonable request, i'll carve out some time.

My initial thinking is to make the defaultOptions an @injectable instead of a flat import and then it can be provided by you on a per module basis where ever you choose to import it.

{ provide: defaultSimpleModalOptions , useValue: <default here> }

Thoughts?

Tahiche commented 6 years ago

Injectable sounds like a good approach, I´m assuming you mean a ConfigService kind of thing that you can inject and thus override/modify. If i´m not mistaken, here... { provide: defaultSimpleModalOptions , useValue: <default here> } You´d be modifying/customizing default Options globally, at Module level?. That´s great, then you could further override if needed by injecting the service at specific components.

kevcjones-archived commented 6 years ago

@Tahiche give that branch a look over. Feedback welcome.

kevcjones-archived commented 6 years ago

I'm going to push this anyway @Tahiche but your feedback on it would be welcome since you initiated the request

Tahiche commented 6 years ago

Hi!, So sorry i missed these comments!. It looks great, thank u very much!!. I´ll check it out. Again, sorry for not answering before I wasn´t noticed and totally missed it.

Cheers!!

EDIT: My fist time messing with git branches and npm packages... It seems like the branch/change is not pushed to node right (current version 1.3.3) ?. Do you clone the branch on the "node_modules/ngx-simple-modal" folder?.