对angularJs中ng-style动态改变样式的实例讲解
时间:2021-08-31 10:00:26|栏目:AngularJS|点击: 次
如下所示:
<!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>
效果图: