Home  >  Q&A  >  body text

javascript - Unsafe situation occurs when using angular to dynamically assign the src attribute to an image

I would like to ask if there are any other ways to remove this unsafe

html code: <p class="user_pic"><img src="{{item.UserID | imgSrc}}" width="100%;" height="178px;"></ p>
In 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;
    }
});
PHP中文网PHP中文网2716 days ago1079

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-06-05 11:12:10

    https://stackoverflow.com/que...

    reply
    0
  • Cancelreply