通过controller.js中的某个$scope变量的值来决定div标签(或者其他html标签)的样式表。

示例

使用ng-style指令在div标签上

<body ng-app="myApp" ng-controller="myCtrl">

<div ng-style="myStyle">菜鸟教程</div>

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
    $scope.myStyle = {
        "color" : "white",
        "background-color" : "coral",
        "font-size" : "60px",
        "padding" : "50px"
    }
});
</script>
</body>

@完

参考:http://www.runoob.com/angularjs/ng-ng-style.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-06
  • 2021-08-17
  • 2022-03-08
  • 2022-01-18
  • 2021-06-13
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2022-01-13
  • 2021-12-19
  • 2021-07-07
  • 2021-07-25
  • 2021-07-06
相关资源
相似解决方案