【问题标题】:Implement Angular Confirm - craftpip实现 Angular Confirm - Craftpip
【发布时间】:2021-01-08 11:32:33
【问题描述】:

我正在尝试使用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');
        },
      },
    });
  });
}

它会弹出以下错误,

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

【问题讨论】:

  • 正如@Moshezauros 所提到的,该库旨在与AngularJS 一起使用。如果您在项目中使用 ng-bootstrap:我在这里为类似问题提供了解决方案:stackoverflow.com/a/48761912/184245

标签: angular typescript confirm


【解决方案1】:

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

【讨论】:

  • 明白。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-02
  • 1970-01-01
  • 1970-01-01
  • 2016-11-02
  • 2017-07-27
  • 2017-09-10
相关资源
最近更新 更多