如下所示:
<!doctype html>
<html lang="en">
<head>
< charset="UTF-8">
< src="angular.min.js"></ >
</head>
<body>
<div ng-app="module" ng-controller="ctrl">
颜色: <input type="text" ng-model="color">
大小: <input type="number" ng-model="size"><br/>
<!--通过输入color和size的值,改变style的值-->
<span ng-style="{color:color,fontSize:size+'px'}">泠泠在路上</span>
</div>
< >
var m = angular.module('module', []);
m.controller('ctrl', ['$scope', function ($scope) {
}]);
</ >
</body>
</html>
效果图:

以上这篇对angularJs中ng-style动态改变样式的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
继续阅读与本文标签相同的文章
-
将制造业作为发展数字经济的主战场!
2026-05-18栏目: 教程
-
如何成为一名优秀的初级开发者?
2026-05-18栏目: 教程
-
展望2025多媒体技术与应用趋势
2026-05-18栏目: 教程
-
“拼下限”的网络直播
2026-05-18栏目: 教程
-
阿里云第六代云服务器特性、实例类型、及可选区域相关介绍
2026-05-18栏目: 教程
