在Angular中,我有加載背景圖像屬性的指令。我如何獲得背景圖像以便按需重新加載?如何重新加載一個指令中的CSS背景圖像
app.directive('profilePhotoPreview', function() {
return {
restrict: "A",
scope: {
uuid: "="
},
template: "",
link: function (scope, element, attrs) {
scope.$watch('uuid', function (value) {
console.log('profilePhotoPreview ',value);
if (scope.uuid) {
scope.preview = "url('"+conf.s3 + "user_profile_photos/" + scope.uuid + ".jpg')";
var s={'width':'400px', 'height':'400px','background-image': scope.preview}
element.css(s);
}
})
}
}
});
在這種情況下,基礎照片已被更改(即新的個人資料照片已上傳),但url是相同的。
我試着在uuid變量上設置一個$ watch,並將它的值從null轉換回原來的值,以便將Angular重新渲染爲css,但這沒有任何效果。
會這樣使用緩存的數據瀏覽器的結果? – 2014-09-24 13:44:37