【问题标题】:Is there any solution to change the style value in AngularJS?是否有任何解决方案可以更改 AngularJS 中的样式值?
【发布时间】:2020-05-26 21:54:10
【问题描述】:

<div class="meter">
  <span style="width: 13%"></span>
</div>

以上是我的 HTML 代码。 我将更改 AngularJS 中的宽度值。 有什么办法可以解决这个问题吗?

【问题讨论】:

标签: javascript css angularjs


【解决方案1】:

您可以为此使用ng-style

<button type="button"  ng-click="changeStyle()">set width</button>
<span ng-style="myStyle">Sample Text</span>

然后使用动态更改跨度的宽度

$scope.changeStyle=function(){
    $scope.myStyle="{width:'20px'}";
}

ng-style reference

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-18
    • 2022-11-17
    • 1970-01-01
    • 2021-04-22
    • 2015-03-05
    • 2021-05-06
    • 2015-08-13
    • 1970-01-01
    相关资源
    最近更新 更多