加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angularjs材质对话框不起作用

发布时间:2020-12-17 17:45:58 所属栏目:安全 来源:网络整理
导读:我有一个项目数组,我想在对话框中输出.我没有收到错误,但它也没有. $scope.showDialog = function (ev) { $mdDialog.alert({ controller: 'DialogController',controllerAs: 'DiaCtrl',templateUrl: 'softwareused.tmpl.html',parent: angular.element(docum
我有一个项目数组,我想在对话框中输出.我没有收到错误,但它也没有.

$scope.showDialog = function (ev) {
      $mdDialog.alert({
        controller: 'DialogController',controllerAs: 'DiaCtrl',templateUrl: 'softwareused.tmpl.html',parent: angular.element(document.body),targetEvent: ev,locals: {
          items: cvLibsUsed
        }
  });
};

这应该打开一个警告对话框,如here所指出的那样
当我尝试demo code时,我收到了错误,没有定义“警报”.

模板看起来像这样:

<md-dialog aria-label="Software used">
<md-dialog-content>
    <h2>Software used</h2>
    <ul>
        <li ng-repeat="cur in locals.items"><a ng-href="{{cur.url}}">{{cur.desc}}</a> - (<a
                ng-href="{{cur.licenceUrl}}">{{cur.licence}}</a>
            )
        </li>
    </ul>
</md-dialog-content>
<md-dialog-actions layout="row">
    <md-button class="md-icon-button" ng-click="close()" aria-label="Close dialog" md-autofocus>
        Close
    </md-button>
</md-dialog-actions>

知道我在这里做错了什么吗?没有AngularJS错误,也没有对话框.

谢谢 :)

解决方法

你应该使用$mdDialog.show而不是$mdDialog.alert

$scope.showDialog = function (ev) {
      $mdDialog.show({
        controller: 'DialogController',locals: {
          items: cvLibsUsed
        }
  });

这是一个样本mdDialog

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读