实现 Angular Confirm -craftpip

问题描述

我正在尝试使用 angular-confirm。但它的文档不清楚。 我尝试按如下方式实现这一点,

图书馆 - https://craftpip.github.io/angular-confirm/

点击按钮(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');
        },},});
  });
}

它弹出以下错误

enter image description here

我正在寻找一些实现此示例的示例,但没有运气。谁能帮我解决这个问题?

解决方法

这个库是用于AngularJs的,它是Angular的前身,所以不能用于Angular项目。您可以尝试其他适合 Angular 的库之一 - 可能类似于 angular-confirmation-popover