** service -
import { Injectable } from '@angular/core';
declare let alertify: any;
@Injectable({
providedIn: 'root'
})
export class AlertifyjsService {
constructor() { }
confirm(message: string ) {
alertify.confirm(message,
function(){
alertify.success('Ok');
},
function(){
alertify.error('Cancel');
});
}
//https://alertifyjs.com/prompt.html
prompt(title: string, message: string, defvalue: string)
{
// alertify.prompt().set(message, title).show();
//alertify.dialog('prompt').set({transition: 'zoom', message}).show();
//alertify.prompt('Input (color):').set('type', 'color');
//alertify.prompt('Input (date):').set('type', 'date');
//alertify.prompt('Input (datetime-local):').set('type', 'datetime-local');
// alertify.prompt('Input (number):').set('type', 'number');
//alertify.prompt('Input (password):').set('type', 'password');
alertify.prompt( 'Prompt Title', 'Prompt Message', 'Prompt Value'
, function(evt: Event,value:string) { alertify.success('You entered: ' + value) }
, function() { alertify.error('Cancel') });
}
success(message: string) {
alertify.success(message);
}
error(message: string) {
alertify.error(message);
}
warning(message: string) {
alertify.warning(message);
}
message(message: string) {
alertify.message(message);
}
}
** component ts
import { Component, OnInit } from '@angular/core';
import {AlertifyjsService} from '../Services/alertifyjs.service';
@Component({
selector: 'app-carousel',
templateUrl: './carousel.component.html',
styleUrls: ['./carousel.component.css']
})
export class CarouselComponent implements OnInit {
constructor(private alertify: AlertifyjsService) { }
ngOnInit(): void {
}
msgSuccess(message: string)
{
this.alertify.success(message);
}
msgWarning(message: string)
{
this.alertify.warning(message);
}
msgError(message: string)
{
this.alertify.error(message);
}
prompt(title: string, message: string, defvalue: string)
{
this.alertify.prompt(title,message,defvalue);
}
confirmX(message: string)
{
this.alertify.confirm(message);
}
}
** component html
<p><a class="btn btn-primary btn-lg hero-button" role="button" (click)='prompt("title","mesaj","defvalue");' >MBOX PROMPT </a></p>
** GitHub public :
https://github.com/doktoralban/angular11OrderApp
Yorumlar
Yorum Gönder