Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to inject / use own config file? Enum import problem #64

Open
woeterman94 opened this issue Aug 28, 2018 · 1 comment
Open

How to inject / use own config file? Enum import problem #64

woeterman94 opened this issue Aug 28, 2018 · 1 comment

Comments

@woeterman94
Copy link

I'm trying to inject my own config based on: https://github.com/artemsky/ng-snotify/blob/master/src/snotify/toastDefaults.ts

But I get errors that the enums could not be found? How can I solve this? Do you have an example on how to inject your own config file?

The instructions at https://artemsky.github.io/ng-snotify/documentation/api/options.html#setting-default-configuration did not help me.

@woeterman94
Copy link
Author

Fixed it by changing the enums to strings.

I created my own new class 'ToastConfig'

import {SnotifyModule, SnotifyService, ToastDefaults} from 'ng-snotify'

export const ToastConfig = {
  global: {
    newOnTop: true,
    maxOnScreen: 8,
    maxAtPosition: 8,
    filterDuplicates: false
  },
  toast: {
    type: 'error',
    showProgressBar: false,
    timeout: 5000,
    closeOnClick: true,
    pauseOnHover: true,
    bodyMaxLength: 150,
    titleMaxLength: 16,
    backdrop: -1,
    icon: null,
    iconClass: null,
    html: null,
    position: "rightBottom",
    animation: {enter: 'fadeIn', exit: 'fadeOut', time: 400}
  },
  type: {
    prompt: {
      timeout: 0,
      closeOnClick: false,
      buttons: [
        {text: 'Ok', action: null, bold: true},
        {text: 'Cancel', action: null, bold: false},
      ],
      placeholder: 'Enter answer here...',
      type: 'prompt',
    },
   confirm: {
      timeout: 0,
      closeOnClick: false,
      buttons: [
        {text: 'Ok', action: null, bold: true},
        {text: 'Cancel', action: null, bold: false},
      ],
      type: 'confirm',
    },
   simple: {
      type: 'simple'
    },
    success: {
      type:  'success'
    },
    error: {
    showProgressBar: false,
    timeout: 5000,
      type: 'error'
    },
    warning: {
      type: 'warning'
    },
    info: {
      type: 'info'
    },
    async: {
      pauseOnHover: false,
      closeOnClick: false,
      timeout: 0,
      showProgressBar: false,
      type: 'async'
    }
  }
};

App module looks like this:

        { provide: 'SnotifyToastConfig', useValue: ToastConfig},
        SnotifyService

You might want to update your documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant