使用 Angular JS 使图像出现在弹出窗口上

2024-05-05

这是我在 StackOverflow 上的第一篇文章,我正在自学 Angular,所以我是一个初学者,目前很困惑。

我正在使用 Angular 创建一个网页,其中一个页面涉及一个按钮和一个弹出窗口。我想将图像放入弹出窗口中,但在实现此操作时遇到很多麻烦。

步骤和名称属性成功出现在弹出窗口中,但图像不起作用。我尝试过让 url 显示为字符串,但这也不起作用。

我还尝试让 id 属性(只是一个字符串)出现,但这也不起作用。

我在 html 中的 ctrl.figure 周围只放了一组大括号,因为这至少会让我在弹出窗口中看到一个损坏的图片图标,而如果我按照通常建议的那样使用两个大括号,我什么也得不到。

我在本地计算机上托管该网站,并使用 Chrome 开发工具,不断收到一条消息,提示找不到该文件。我已经多次检查了文件路径,看起来没问题。由于我无法让图形的 url 仅显示为字符串,因此我认为问题可能与控制器有关。

任何建议将不胜感激。第一组代码是弹出窗口的 html,第二组代码来自控制器。

<!--Overlay div for popup window-->
    <div ng-show= "ictrl.showValue" class="instAbsolute col-xs-12 col-md-10 ng-cloak">
        <span class= "glyphicon glyphicon-remove pull-right" ng-click = "ictrl.hideDetails()"></span>
        <h4 class = "text-muted" >{{ictrl.step}}</h4>
        <h1 class = "text-grey">{{ictrl.name}}</h1>
        <h1 class = "text-grey">{{ictrl.id}}</h1>
        <div ng-bind-html="ictrl.description">
        </div>
          <img class= "img-responsive" ng-src="{ictrl.figure}" alt="{{ictrl.alt}}">
    </div> 
   </div> <!--end of controller -->
</div> <!--end of app -->
angular.module('instructionsApp', ['ngSanitize']).controller('instructionsCtrl',[

    function() {
        var self = this;
        self.showValue = false;
        self.showDetails = function(id) {
            for (var i = 0; i < this.steps.length; i++) {
                if (self.steps[i].id === id) {
                    self.name = self.steps[i].name;
                    self.step = self.steps[i].step;
                    self.description = self.steps[i].description;
                    self.showValue = true;
                }
            }
        };
        self.hideDetails = function() {
            self.showValue = false;
        };
        self.steps = [{
        {
            name: "Attach Camera",
            id: "S1",
            step: "Setup",
            description: "<p>There are many ways to attach you camera to your laptop.&nbsp; For digital camera output, we recommend connecting the camera with a wire to the faster firewire port &ndash; but the USB port will also work.&nbsp; As an example, for analog camera output you can use an external capture device (such as the Dazzle from Pinnacle) with a 3-port composite connector into the camera and a USB connection on the other end of the cable into the laptop.&nbsp; Also, there are many ways to interface a camera to an internal video capture card.&nbsp; See illustrations below:<\/p>"
        }, {
            name: "Launch VazztCaster",
            id: "S2",
            step: "Setup",
            figure: "../img/instructionsImages/launchVazztCaster.jpg",
            description: "<p>Launch the VazztCaster.exe program on your laptop by clicking on the Vazzt icon (red V) on your desktop. &nbsp;After launch, on the home page of VazztCaster click on the Login Icon (person) and enter the Credentials:<\/p><p>Next Click on the Video Settings Icon (blue camcorder)&nbsp; and enter your choice of&nbsp;<\/p><p>&nbsp;<\/p><p>Note that the VazztCaster will automatically set default values, if possible, in the Video Settings fields based on the camera attached, the IP networks it finds, and the audio equipment attached:<\/p><ul><li>Video Capture Devices<\/li><li>Video Resolution<\/li><li>Video Bandwidth<\/li><li>Aspect Ratio<\/li><li>Audio Capture Device<\/li><li>And other Audio parameters.&nbsp;<\/li><\/ul><p>However, you can manually override these.&nbsp; Click the OK button when you are finished.<\/p><p>Most cameras will automatically provide notification of the various resolutions that the camera can support.&nbsp; VazztCaster can detect this and by examining the bandwidth detected, also automatically, VazztCaster sets default resolution and bandwidth.<\/p><p>&nbsp;<\/p><p>&nbsp;<\/p>",
            alt: "Launch VazztCaster",
            imageCaption: "After launching VazztCaster, this is what your screen should look like."
        }];
    }
]);

在你的 instructionsController.js 中 -

self.showDetails = function(id) {
    for (var i = 0; i < this.steps.length; i++) {
        if (self.steps[i].id === id) {
            self.name = self.steps[i].name;
            self.step = self.steps[i].step;
            self.description = self.steps[i].description;



    ## self.figure = self.steps[i].figure;
    ## self.alt = self.alt[i].alt;
    ## self.imageCaption = self.imageCaption[i].imageCaption

            self.showValue = true;
        }
    }
};

开头的行##是您需要添加的内容所以基本上您忘记了循环上面突出显示的行。 希望这可以帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Angular JS 使图像出现在弹出窗口上 的相关文章

随机推荐

  • Adobe Flash 项目的版本控制

    我正在处理一个非常复杂的 Flash 项目 该项目是我们为客户使用而部署的全套服务的一部分 对于我们的大多数软件源 Java PHP Javascript HTML 和一些其他语言的支持脚本 我们使用 subversion 进行版本控制和管
  • Android - 减少位图绘制的内存使用量

    我的应用程序中有一张地图 显示了 Gowalla 的位置 我使用带有简单默认标记的 ItemizedOverlay 但在绘制项目时 我将默认标记替换为从 Gowalla 下载 9 并缓存在磁盘上 的位置图标 问题是 如果屏幕上有很多位置 例
  • 查找 SSIS 包上次修改/部署日期 - SQL Server

    我想通过执行 SQL 查询找到 SSIS 包的最后修改日期 例如 下面的查询按降序返回过程的最后修改日期 我期待对 SSIS 包进行同样类型的查询 可以从DB获取这些信息吗 select name create date modify da
  • Pytest - 如何将参数传递给 setup_class?

    我有一些代码 如下所示 我得到了too few args当我运行它时出错 我没有打电话setup class明确地 所以不确定如何向它传递任何参数 我尝试用以下方法装饰该方法 classmethod 但仍然看到相同的错误 我看到的错误是这样
  • STDOUT->autoflush(1) 在 Perl 中做什么?

    我找到了有关 Perl 中自动刷新的各种信息 但找不到任何提及格式完全相同的行 STDOUT gt autoflush 1 这包含在我正在分析的程序中 我想更好地了解它的作用 程序开头还有这样一段话 use IO Handle 我认为这可能
  • 如何编辑多个 Pandas DataFrame 浮点列的字符串格式?

    我有一个pd DataFrame浮点数 import numpy as np import pandas as pd pd DataFrame np random rand 5 5 0 1 2 3 4 0 0 795329 0 125540
  • Chrome 扩展允许的键盘快捷键

    当您创建 Chrome 浏览器扩展程序时 您可以通过实现来建议键盘快捷键chrome 命令 https developer chrome com extensions commandsAPI 是否有允许的组合键的记录列表 Chrome 似乎
  • 遍历多行字符串

    我得到一些数据 def data some useless text n even more n finally interesting text 我怎样才能得到其中 有趣的部分 所以基本上所有行都不是以 开头的 Groovy 的一种选择是
  • 如何将sublime默认View设置为2行

    每次我打开 sublime 我都会执行以下操作 Layout then Rows 2 我可以更改设置 以便当我打开 sublime 时这是默认设置吗 我不知道有什么设置可以控制新创建的窗口的布局 它们始终创建为单个文件组 最好 最简单的事情
  • 是否可以从猫鼬文档中获取模型?

    var UserSchema new Schema Schema var User mongoose Model User UserSchema Model var user new User Document 仅给定文档 在本例中为用户
  • 如何使用实体框架更新特定记录的一个字段?

    我想要更新一个名叫 Pejman 的人的家庭情况 这是我的对象类 public class Person public int Id get set public string FirstName get set public string
  • 使用 CSS 更改文本选择颜色?

    我目前正在开发一个网站 我想更改文本选择颜色 我已经有点工作了 这是我的样式表中的代码 部分 selection background FF0099 color black text shadow none moz selection ba
  • 在 C、C++ 中实现腐蚀、膨胀

    我对二值图像的膨胀是如何完成的有理论上的了解 AFAIK 如果我的 SE 结构元素 是这样的 0 1 1 1 在哪里 代表中心 我的图像 二进制是这样的 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0
  • 在 SDK 中找不到文件夹“tools”

    我在做安卓开发使用 Eclipse 我已经下载了所有必需的软件 但遇到了与中讨论的相同的问题 无法在 Eclipse 中设置 Android Target https stackoverflow com questions 6384328
  • UITableView更改标题标题颜色

    我正在设计 UITableView 的样式应用内设置工具包 http InAppSettingsKit并想要更改标题的颜色 标签Without title and Text Field应该是白色的 如何才能做到这一点 Thanks 这是一个
  • 我们可以使用 axios 的 onDownloadProgress 来加载 API 吗?

    我需要使用 axios 创建一个用于在 React 项目中加载 API 的进度条 我为此发现了 onDownloadProgress 函数 但我不知道我们是否可以使用它来获取诸如加载百分比之类的信息 或者它是否仅用于文件下载 所以我不确定我
  • 如何通过 SyliusResourceBundle 使用 Sylius 创建新模型

    我找到并成功使用了有关如何覆盖 Sylius 中现有模型的文档 但我无法利用 SyliusResourceBundle 创建一个全新的模型 我猜如果你已经了解 Symfony2 的话这很容易吗 我仍在学习 所以这就是我所拥有的 我缺少什么
  • 在 JDBC PL/SQL 块中多次使用命名参数时出错

    当使用命名参数调用 PL SQL 块时出现错误 当所有命名参数仅使用一次时 我的代码工作正常 但是当我复制标有 SQL 的 SQL 时 然后所有命名参数 以冒号开头 q 都使用了两次 现在我得到一个 SQL 异常 它说 参数名称的数量与注册
  • invoke_result获取模板成员函数的返回类型

    如何获取模板成员函数的结果类型 下面的最小示例说明了该问题 include
  • 使用 Angular JS 使图像出现在弹出窗口上

    这是我在 StackOverflow 上的第一篇文章 我正在自学 Angular 所以我是一个初学者 目前很困惑 我正在使用 Angular 创建一个网页 其中一个页面涉及一个按钮和一个弹出窗口 我想将图像放入弹出窗口中 但在实现此操作时遇