2

I've got Alertify working in my Angular 8 Project. Now I wanted to change the title in the dialog box that appears when alertify.alert is invoked. The Documentation says this can be done by using the overload that accepts the title: alertify.alert('Title', 'Message') but when I try to use this the IDE already tells me that this is an invalid numbers of parameters and at run time the messages box still appears but the Title is not set.

How is this done?

Edit 1

Versions:

  • Angular: 7.3.8
  • Alertifyjs: 1.12.0

How I've integrated it:

In angular.json

"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"src/styles.css"
],
"scripts": [
"node_modules/alertifyjs/build/alertify.min.js"
]

entries in styles.css

@import "../node_modules/alertifyjs/build/css/alertify.min.css";
@import "../node_modules/alertifyjs/build/css/themes/bootstrap.min.css";

The service:

Import {Injectable} from '@angular/core';

declare let alertify: any;

@Injectable({
  providedIn: 'root'
})

export class AlertifyService {

  constructor() {
  }

  error(message: string) {
    alertify.alert('MyApp', message);
  }
}
Marco Rebsamen
  • 605
  • 7
  • 30
  • 1
    As you well said, that method in alertify does take two arguments, it is mentioned in the documentation. So that is probably not the problem, so maybe you could share a bit more of your code? Maybe the way you are importing the library could be the problem, I don't know, but it's impossible to tell the problem from the information you provided. That's probably why people have been downvoting you. – David G. Oct 27 '19 at 17:58
  • You will also have to make sure that the version of alertify you are using matches the version of the documentation you are using. And also check the version the types are created for in the DefinitelyTyped repo – C.OG Oct 27 '19 at 19:50
  • Ok... I get the point. The Reason why I did not add the code is because it's the basic implementation they recommend on their page for getting started. Anyways, I've added it now. Thank you. – Marco Rebsamen Oct 28 '19 at 09:51

1 Answers1

0

I've figured it out. The problem was the scripts entry:

wrong:

"scripts": [
  "node_modules/alertifyjs/build/alertify.min.js"
]

correct:

"scripts": [
  "./node_modules/alertifyjs/build/alertify.min.js"
]

Funny that alertify did work somehow with the wrong line

Marco Rebsamen
  • 605
  • 7
  • 30