ng风格的背景颜色不起作用

时间:2017-02-28 11:59:02

标签: angularjs

嗨朋友们,我是angularjs.i的初学者,如果从控制器那里向ng-style显示背景颜色



var app = angular.module("myApp", []).controller("myCtrl", function($scope) {
  $scope.color = 'yellow';
  $scope.zoom = 2;
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<div ng-app="myApp" ng-controller="myCtrl" ng-style="{'background-color': color }">
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:-1)

&#13;
&#13;
var app = angular.module("myApp", []).controller("myCtrl", function($scope) {
  $scope.color = 'yellow';
  $scope.zoom = 2;
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

<div ng-app="myApp" ng-controller="myCtrl" ng-style="{'background-color': color }">
welcome
</div>
&#13;
&#13;
&#13;