百度過後,在appmodule中設定了app.config的值$compileProvider.imgSrcSanitizationWhitelist(/^s*(https?|local|data):/);
但是沒有效果
想問大家還有什麼其他辦法可以去掉這個unsafe
html程式碼: <p class="user_pic"><img src="{{item.UserID | imgSrc}}" width="100%;" height="178px;"></ p>
controller中:app.filter('imgSrc', function () {
return function (input) {
var src = '';
if (input == undefined) {
return;
}
$.ajax({
url: BaseURL + "/MainUser/LoadUserPersonalHomepageByUseriD?userID=" + input,
type: 'get',
async: false,
success: function (data) {
if (data.UploadIMG == null) {
src = '/img/tp.png'
} else {
src = data.UploadIMG
}
}
})
return src;
}
});