AngularJS ng-style
Yönergesi
Örnek
CSS anahtarlarına ve değerlerine sahip bir nesne kullanarak AngularJS ile biraz stil ekleyin:
<body ng-app="myApp" ng-controller="myCtrl">
<h1 ng-style="myObj">Welcome</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>
Tanım ve Kullanım
Yönerge ng-style
, HTML öğesi için stil niteliğini belirtir.
Özniteliğin değeri ng-style
bir nesne veya bir nesneyi döndüren bir ifade olmalıdır.
Nesne, anahtar değer çiftlerinde CSS özelliklerinden ve değerlerinden oluşur.
Sözdizimi
<element ng-style="expression"></element>
Tüm HTML öğeleri tarafından desteklenir.
Parametre Değerleri
Value | Description |
---|---|
expression | An expression which returns an object where the keys are CSS properties, and the values are CSS values. |