【问题标题】:Can't bind to property since it isn't a known property of element无法绑定到属性,因为它不是元素的已知属性
【发布时间】:2020-07-01 11:03:02
【问题描述】:

我正在尝试向我的 ion-fab-button 元素添加动态标签,但我似乎无法让它工作,因为我需要能够从变量中提供值但我无法绑定到属性.我尝试了以下方法,但看到了错误:

错误:模板解析错误:无法绑定到“desc”,因为它不是“ion-fab-button”的已知属性。

<ion-fab-button
  color="success"
  [disabled]="true"
  desc="Already Sent Scale: {{ variable }}"
  class="labelOnRight"
>
  <i class="fa fa-presentation fs-24"></i>
</ion-fab-button>

在我的 css 中,我使用 desc 创建标签:

ion-fab-button.labelOnRight[desc]::after {
  position: absolute;
  content: attr(desc);
  z-index: 1;
  left: 55px;
  bottom: 6px;
  background-color: var(--ion-color-primary);
  padding: 5px 9px;
  border-radius: 15px;
  color: white;
  box-shadow: 0 3px 5px -1px rgba(0,0,0,0.2), 0 6px 10px 0 rgba(0,0,0,0.14), 0 1px 18px 0 rgba(0,0,0,0.12);
}

有没有办法做到这一点?当desc 属性被硬编码时一切正常,但当它是动态时则不行。

【问题讨论】:

    标签: angular ionic-framework


    【解决方案1】:

    使用数据属性:&lt;ion-fab-button [attr.data-desc]&gt;&lt;/ion-fab-button&gt;

    【讨论】:

      【解决方案2】:

      我认为你需要设置属性。我正在打电话,所以无法测试,但如果它有效,请告诉我。

      试试[attr.desc]="'已经发送比例'+变量"

      【讨论】:

        猜你喜欢
        • 2017-02-03
        • 2019-10-10
        • 1970-01-01
        • 2021-07-11
        • 2017-06-21
        • 2019-11-04
        • 2020-06-21
        • 2023-02-01
        • 2015-09-16
        相关资源
        最近更新 更多