【问题标题】:ng2-material : change dialog contentng2-material : 改变对话框内容
【发布时间】:2016-04-18 11:04:27
【问题描述】:

我正在使用 ng2-material 来构建我的 angular2 应用程序。 ng2-material 只提供了两种基本的对话组件,但我需要更改它们的内容。

所以我需要知道我该怎么做? 这就是我正在使用的

   let config = new MdDialogConfig()
        .textContent(``)
        .clickOutsideToClose(true)
        .title('')
        .ariaLabel('Lucky day')
        .ok('save')
        .cancel('cancel')
        .targetEvent(ev);

    this.dialog.open(MdDialogBasic, this.element, config)
        .then((ref: MdDialogRef) => {
            ref.whenClosed.then((result) => {
                if (result) {
                    this.status = 'You decided to get rid of your debt.';
                }
                else {
                    this.status = 'You decided to keep your debt.';
                }
            })
        });

我无法识别 template URL 来代替 textContent,就像在 Angular 材料中一样:

$mdDialog.show({
  controller: DialogController,
  templateUrl: 'dialog1.tmpl.html',
  parent: angular.element(document.body),
  targetEvent: ev,
  clickOutsideToClose:true,
  fullscreen: useFullScreen
})

【问题讨论】:

    标签: angular angular-material


    【解决方案1】:

    您可以像这样使用模板的 url 作为 textContent:

     let config = new MdDialogConfig()
        .textContent('dialog1.tmpl.html')
        .clickOutsideToClose(true)
        .title('')
        .ariaLabel('Lucky day')
        .ok('save')
        .cancel('cancel')
        .targetEvent(ev);
    

    它对我有用,所以希望它对你有用。

    【讨论】:

      猜你喜欢
      • 2016-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多