
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ng-snotify
Advanced tools
[](https://travis-ci.org/artemsky/ng-snotify) [](https://www.npmjs.com/package/ng-snotify) [ if you have build errors
SnotifyModule
],
providers: [SnotifyService],
bootstrap: [AppComponent]
})
export class AppModule { }
Add app-snotify
component to you root component
<!-- You can now use your library component in app.component.html -->
<app-snotify></app-snotify>
Now you should inject SnotifyService
import {Component, OnInit} from '@angular/core';
// Import SnotifyService
import {SnotifyService} from 'ng-snotify';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
// Inject SnotifyService
constructor(private snotifyService: SnotifyService) {}
//You can set global config like this
ngOnInit() {
this.snotifyService.setConfig({
timeout: 30000
}, {
newOnTop: false,
});
}
//Hopefuly you can add a toast
addToast() {
this.snotifyService.error('Example error!', 'Here we are', {
closeOnClick: false
});
}
//You can remove all toasts from the field
clearToasts() {
this.snotifyService.clear();
}
}
SnotifyService
has method setConfig
, wich takes 2 parametrs
1 - Object typeof SnotifyConfig
or null
export interface SnotifyConfig {
timeout?: number;
showProgressBar?: boolean;
type?: SnotifyType;
closeOnClick?: boolean;
pauseOnHover?: boolean;
buttons?: [SnotifyButton, SnotifyButton] | [SnotifyButton];
}
2 - Object typeof SnotifyOptions
or null
export interface SnotifyOptions {
maxOnScreen?: number;
newOnTop?: boolean;
position?: SnotifyPosition;
transition?: number;
}
You can call toast by calling one of this methods from SnotifyService
instance
success(title: string, body: string, config?: SnotifyConfig): number
info(title: string, body: string, config?: SnotifyConfig): number
warning(title: string, body: string, config?: SnotifyConfig): number)
error(title: string, body: string, config?: SnotifyConfig): number)
simple(title: string, body: string, config?: SnotifyConfig): number
confirm(title: string, body: string, config: SnotifyConfig): number)
prompt(title: string, body: string, config: SnotifyConfig): number)
async(title: string, body: string, config: SnotifyConfig): number)
All toast methods return id
, so you can remove toast by calling snotifyService.remove(id)
If you call snotifyService. remove()
without id, it will affect all toasts, the same is snotifyService.clear()
const id = snotifyService.simple('Example title!', 'Example body message', {
timeout: 0, // disable timeout,
showProgressBar: true, // won't affect because of timeout, if timeout set to 0. Progress Bar cannot exist anymore
closeOnClick: false,
pauseOnHover: true // won't affect because of timeout
});
this.snotifyService.remove(id)
There are few lifecycle hooks
onInit
- when toast has been shownonClick
- when toast has been clickedonHoverEnter
- on mouse enteronHoverLeave
- on mouse leavebeforeDestroy
- before toast destroyedafterDestroy
- after toast has been destroyed
You can set it with snotifyService
this.snotifyService.onInit = (toast: SnotifyToast) => {
// Do something here
};
All interfaces can be imported from ng-snotify
The best place to set global config is ngOnInit()
Documentation - here.
Examples - here
npm run build
cd src
npm link
cd ..
npm link ng-snotify
npm run build:watch
ng serve --open
localhost:4200
in your browser./src
MIT © artemsky
truncate
pipetitleMaxLeght
and bodyMaxLeght
to SnotifyConfig
maxHeight
to SnotifyOptions
(#7)placeholder
of SnotifyConfig
typeng2-snotify
due semantic purposev1.1.4
FAQs
Angular 2+ notifications center
The npm package ng-snotify receives a total of 2,644 weekly downloads. As such, ng-snotify popularity was classified as popular.
We found that ng-snotify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.