我似乎无法使用控制器来设置div的CSS背景属性.到目前为止,这是我的代码,根据文档:
HTML:
@H_301_3@<div class="hero" ng-controller="HeroCtrl" ng-style="heroImage"></div>JS:
@H_301_3@'use strict'; angular.module('AppliedSiteApp').controller('HeroCtrl',function ($scope) { $scope.heroImage = { background: 'images/brick.jpg' }; console.log($scope.heroImage); });CSS:
@H_301_3@.hero { width: 100%; min-height: 350px; background-position: center center; }我也尝试在Fiddle here中复制这个设置.有没有人有任何想法?
@H_301_3@$scope.heroImage = {
background: 'url(images/brick.jpg)'
};
background-image需要url()才能工作.