1

这是我的第一个问题。请多多包涵。

我有一个表格,其中一个列显示图像,而不是在表格的列中显示图像,我想在用户单击查看图像时将其更改为同一窗口上的弹出图像。我尝试使用 windows.open(imgSrc),弹出新窗口(我没有打开新窗口)并下载图像。我附上了我的一段代码。请帮我。

身体

<td data-title='"Background Image"' header-class='text-left'><a href="#" ng-click="Page.Functions.GetBackgroundImageUrl(item)">View Image</a></td>

JS

$scope.Page.Functions.GetBackgroundImageUrl = function (hero) {

    if (hero && hero.BackgroundImageExist) {

        var v = $scope.Page.Functions.GetDataVersion(hero.Id);
        if (v) {
            v = '?v=' + v;
        }

        window.open(ENV.apiUri + 'HomePageHero/BackgroundImage/' + hero.Id + v, "window Title", "width = 500, height = 450");
    }

    return null;
}

在表格列中显示图像的代码

<td data-title='"Background Image"' header-class='text-left'><display-media model='Page.Functions.GetBackgroundImageUrl(item)'></display-media></td>

JS

$scope.Page.Functions.GetHtmlText = function (rawText) {
    return $sce.trustAsHtml(rawText);
}

$scope.Page.Functions.GetBackgroundImageUrl = function (hero) {

    if (hero && hero.BackgroundImageExist) {
        var v = $scope.Page.Functions.GetDataVersion(hero.Id);
        if (v) {
            v = '?v=' + v;
        }
        return 'imageUrl:' + ENV.apiUri + 'HomePageHero/BackgroundImage/' + hero.Id + v;
    }

    return null;
}
4

1 回答 1

1

您正在传递window.open将打开一个新浏览器窗口的图像,这就是它的工作,您正在寻找一个模式来打开图像。

我建议尝试Modaal并根据页面上的 Single Image Modal 示例调整您的代码。

于 2020-05-20T03:23:51.953 回答