Search code examples
angulartypescriptconfirm

Implement Angular Confirm - craftpip


I am trying to use angular-confirm. But it's documentation is not clear. I try to implement this as follows,

Library - https://craftpip.github.io/angular-confirm/

In button click (login.component.ts),

ButtonOnClickHandler() {
angular.module('myApp', ['cp.ngConfirm'])
  .controller('myController', function($scope, $ngConfirm){
    $scope.hey = 'Hello there!';
    $ngConfirm({
      title: 'What is up?',
      content: 'Here goes a little content, <strong>{{hey}}</strong>',
      contentUrl: 'template.html', // if contentUrl is provided, 'content' is ignored.
      scope: $scope,
      buttons: {
        // long hand button definition
        ok: {
          text: 'ok!',
          btnClass: 'btn-primary',
          keys: ['enter'], // will trigger when enter is pressed
          action: function(scope) {
            $ngConfirm('the user clicked ok');
          }
        },
        // short hand button definition
        close: function(scope){
          $ngConfirm('the user clicked close');
        },
      },
    });
  });
}

It popups following error,

enter image description here

I seek some examples that implemented this one but no luck. Can anyone help me to sort out this?


Solution

  • This library is for AngularJs, which is Angular's predecessor, so you can't use it for an Angular project. You can try one of the other libraries out there suited for Angular - maybe something like angular-confirmation-popover