對angularJs中ng-style動態(tài)改變樣式的實例講解
更新時間:2018年09月30日 14:20:47 作者:泠泠在路上
今天小編就為大家分享一篇對angularJs中ng-style動態(tài)改變樣式的實例講解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:
<!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動態(tài)改變樣式的實例講解就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
angular-ngSanitize模塊-$sanitize服務詳解
本篇文章主要介紹了angular-ngSanitize模塊-$sanitize服務詳解 ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-06-06angular4自定義表單控件[(ngModel)]的實現(xiàn)
這篇文章主要介紹了angular4自定義表單控件[(ngModel)]的實現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-11-11Angular 的 Change Detection機制實現(xiàn)詳解
這篇文章主要為大家介紹了Angular 的 Change Detection機制實現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-10-10