Ionic:如何以编程方式更改 $ionicPopup 子标题的文本?

Ionic: How is it possible to change $ionicPopup subTitle's text programmatically?

我正在尝试更改与我的应用中某处的 $ionicPopup 关联的 subText 属性的值和样式。

找遍了,还没找到方法。

那怎么可能呢?

谢谢。

如果你想在显示后更改弹出窗口, 您可以使用选择器和 angular jqlite 包装器。

代码是这样的

onTap: function(e) {
          var result = document.getElementsByClassName("popup-sub-title");

           angular.element(result).html('dsaadsds')
           e.preventDefault();
        }

您有 here 可用的代码笔。

您不能直接使用配置选项更改 subTitle,因为在 specification 中定义它接受可选的 String

{
title: '', // String. The title of the popup.
cssClass: '', // String, The custom CSS class name
subTitle: '', // String (optional). The sub-title of the popup.
}

更新:

可以给onTap内的$scope属性赋值,赋值成功提示

{
    text: '<b>Save</b>',
    type: 'button-positive',
    onTap: function(e) {
      $scope.success = {
        message: 'Hello World!'
      };

      e.preventDefault();
    }
  }

现在您可以访问 $scope.success.message 以显示成功消息