javascript - 当我使用 ngstyle 时为 "Cannot find a differ supporting object"

标签 javascript angularjs angular2-styleguide

我确实有一个进度条

<div class="progress-bar-line red" role="progressbar"  
    aria-valuenow="redrated" aria-valuemin="0" aria-valuemax="100"
    ngStyle="max-width:{{redrated}}%"
>
    <span class="title">{{ redrated }}%</span>
</div>

我已经使用了 ngStyle="max-width:{{rederated}}%" 并尝试了尝试:

  1. 在组件中创建了一个对象并以 ng 风格调用它
  2. 即使 ngStyle="{'max-width': '20px' }" 也给出了相同的错误,请帮我解决这个问题

最佳答案

    <!DOCTYPE html>
    <html>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
    <body>
    <div ng-app="myApp" ng-controller="myCtrl">    
    <div class="progress-bar-line red" role="progressbar"  
                aria-valuenow="redrated" aria-valuemin="0" aria-valuemax="100"
                ng-style="{'max-width': '{{redrated}}%'}">
                <span class="title">{{ redrated }}%</span>
            </div>
    </div>
    
    <script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope) {
        $scope.redrated = 20;
    });
    </script>
    </body>
    </html>

关于javascript - 当我使用 ngstyle 时为 "Cannot find a differ supporting object",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48337649/

相关文章:

javascript - AjaxFileUpload 语法错误 : missing } in XML expression

javascript - 什么是 ES6 等效于 module.exports = { key : "value" }?

javascript - 将 MySQL 行计数传递给 JavaScript

javascript - HTML 表格中的 AngularJS

javascript - AngularJS - 最佳实践 : model properties on view or function calls?

css - 在 Angular2 应用程序开始不起作用之前设置加载状态的样式?

javascript - 如何使用 getElementsByClassName 使文本在 Javascript 中出现和重新出现?

php - Laravel Api 路由加载失败。 404 未找到

Angular 2 - 如何有条件地向我的组件添加样式?