【发布时间】:2016-08-14 20:26:21
【问题描述】:
我想实现一个动画词云。由于我没有找到任何 angular 或 Ionic 插件来做我想做的事,我决定(而且我发现学习很有趣)为 jquery 代码创建一个 angular 包装器。 插件为tagcanvas,使用示例为this
到目前为止我做了什么:
- 我将 jquery js 文件添加到我的 index.html 中
- 我在声明指令的地方创建了一个 js 文件,并将其添加到 index.html:
tagcanvas.js
angular.module('tagCanvas', [])
.directive('tagCanvas', function() {
return {
restrict: 'E',
link: function (scope, element, attrs) {
element.tagcanvas({
outlineColour: attrs.outlineColour,
reverse: attrs.reverse,
depth: attrs.depth,
maxSpeed: attrs.maxSpeed,
textFont: attrs.textFont,
textColour: attrs.textColour,
weightMode: attrs.weightMode,
weight: attrs.weight
}, attrs.canvas);
}
};
});
正如您在 codepen 示例中看到的,我需要调用一些属性,以及一个 html 元素 id canvas,我不知道如何在我的指令中调用它们。
我的第二个问题是我不知道如何创建和调用要在我的标签云中显示的单词。 我看了很多教程,但我仍然不知道该怎么做。任何帮助将不胜感激。
【问题讨论】:
标签: javascript jquery html angularjs ionic-framework