我是角色的新手并试图在创建wordcloud时运行此代码而我的指令未被调用。我错过了什么吗?
angular.module('pivot.directives', ['charts.wordcloud'])
.directive('cloud', function (wordcloud) {
console.log("here");
return {
restrict: 'C',
scope: { words: "=words", live: "=live", interval: "=interval", callback: "=callback" },
link: function ($scope, elem, attrs) {
function init() {
elem.empty();
$scope.wordCloud = wordcloud.WordCloud(elem.width(), elem.width() * 0.75, 250, $scope.callback, elem);
}
init();
/** re-initialize wordCloud on window resize */
$(window).resize(function () { _.throttle(init, 1000)(); });
}
}
});
我的HTML
<div id="wordCloud" class="cloud" data-words="words" data-live="live" data-interval="200"
data-callback="addSearchString">
</div>