首页 > 编程 > JavaScript > 正文

对angularJs中ng-style动态改变样式的实例讲解

2019-11-19 12:48:21
字体:
来源:转载
供稿:网友

如下所示:

<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <script src="angular.min.js"></script></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><script> var m = angular.module('module', []); m.controller('ctrl', ['$scope', function ($scope) { }]);</script></body></html>

效果图:

angularJs ng-style动态改变样式

以上这篇对angularJs中ng-style动态改变样式的实例讲解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表