Hanyar abin AngularJS ng-style

Tabbatar da Hanyar abin da ke daidai

ng-style Hanyar abin ke fassara abin HTML na zane Hanyar abin

ng-style Hanyar abin ya kasance abin da ke kewaye ko kuma hanyar abin da ke cewa abin da ke kewaye.

Hanyar abin ya kasance abin da ke kewaye kuma yana da abin da ke daidai wa hanyar CSS da abin da ke daidai.

Tunawa

Ayyuka da ayyuka, ta'a fi hanyar CSS da abin da ke daidai, ta'a fi AngularJS kara kara zane:

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

Try It Yourself

Syntax

<element ng-style="expression</element>

All HTML elements support.

Parameters

Parameters Description
expression Expression, returns an object where the key is the CSS property and the value is the CSS value.