html里:
<div class="text-center" ng-style='storeDetailMainPictrue'></div>controller里:
$scope.PictruePath = Constant.url + $scope.storeDetailMainData.companyInfo[0].LOGO_PATH; $scope.storeDetailMainPictrue = { 'background-image': 'url(' + $scope.PictruePath + ')', 'background-repeat':'no-repeat', 'background-color':'#000000' };解析:(1)'background-image': 'url(' + $scope.PictruePath + ')',想让$scope.PictruePath成为变量,就得‘url(’为一个字符串,‘)’为一个字符串。
(2)ng-style
ng-style 属性值必须是对象,表达式返回的也是对象。