【问题标题】:What would be the proper way to handle SVG file manipulation when using AngularJS使用 AngularJS 时处理 SVG 文件操作的正确方法是什么
【发布时间】:2014-02-25 14:30:48
【问题描述】:

在 AngularJS 应用程序中,处理 SVG 文件操作的正确方法是什么?我提出 AngularJS 的原因是我读到混合使用 jQuery 和 AngularJS 并不是一个好主意。

我有一张可以加载的地图:

<object height="600" width="800" data="/images/map.svg" type="image/svg+xml">
</object>

代表国家/地区的&lt;path&gt; 示例:

  <path class="land ly" d="bunch of coordinates here..." id="country_id"/>

当光标在某个国家/地区上方时,我已经能够使用 CSS 规则填充不同的颜色,如下所示:

.country_id:hover {
  opacity:    1;
  fill:       #ff0000;
}

现在,我想在点击一个国家/地区时触发一个 Javascript 函数,我该如何处理,记住 jQuery 在这里不是一个很好的解决方案?

【问题讨论】:

    标签: angularjs svg


    【解决方案1】:

    向路径元素添加 onclick 属性,例如onclick="alert('你好!');"

    【讨论】:

      猜你喜欢
      • 2013-07-24
      • 2015-08-07
      • 1970-01-01
      • 2011-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      • 2011-04-01
      相关资源
      最近更新 更多