我的自定義背景圖片沒有出現在AngularJS中。無法弄清楚原因。背景圖片沒有出現在AngularJS中
當我測試在控制檯$scope.setBackground
,我得到的對象{background-image: "url(image.jpg)"}
控制器:
app.controller('backgroundImageCtrl', function($scope, $http) {
$scope.setBackground = {
'background-image' : 'url(image.jpg)'
};
})
HTML:
<script type = "text/ng-template" id="/page.html" ng-controller="backgroundImageCtrl" ng-style="setBackground">
<div>
...
</div>
</script>
你應該在使用你的模板的div中使用setBackground。 –
我認爲這是因爲'background-image'在'template'標籤上。這應該是內在的因素。 –
是你的問題回答了嗎? –