javascript - "TypeError: Cannot read property ' jqcloud中默认' of undefined"

标签 javascript angularjs angularjs-directive

我正在使用jqcloud指示。我遵循了文档中描述的所有步骤。但仍然不起作用。

我的代码:

HTML

<div class="item" href="/clients"></div>

  <ion-content ng-controller="clientsController as clients" style="margin-top: 25px">

<div class="demo">

  <jqcloud words="clients.words" width="500" height="350" steps="7"></jqcloud>
</div>

JS:

    angular.module('starter.clientsController', ['ionic', 'angular-jqcloud'])
.controller('clientsController', function ($scope){

$scope.words = [{text: "Lorem", weight: 13},
  {text: "Ipsum", weight: 10.5},
  {text: "Dolor", weight: 9.4},
  {text: "Sit", weight: 8},
  {text: "Amet", weight: 6.2},
  {text: "Consectetur", weight: 5},
  {text: "Adipiscing", weight: 5},];

});

更新:

问题是我没有添加 jqcloud.js 文件,我只添加了包装器。 现在,我没有收到错误,但收到一个空白页。

最佳答案

您已使用#demo id,但从未在 HTML 代码中使用过: 请尝试以下操作:

  <div class="item" href="/clients"></div>
  <ion-content ng-controller="clientsController" style="margin-top: 25px">
      <div id='demo' width="500" height="350" steps="7"></div>
  </ion-content>

Angular 部分:

angular.module('starter.clientsController', ['ionic', 'angular-jqcloud'])
.controller('clientsController', function ($scope){

$scope.words = [{text: "Lorem", weight: 13},
  {text: "Ipsum", weight: 10.5},
  {text: "Dolor", weight: 9.4},
  {text: "Sit", weight: 8},
  {text: "Amet", weight: 6.2},
  {text: "Consectetur", weight: 5},
  {text: "Adipiscing", weight: 5},];

$('#demo').jQCloud($scope.words);
});

关于javascript - "TypeError: Cannot read property ' jqcloud中默认' of undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36692865/

相关文章:

javascript - Ajax 调用触发错误事件但返回 200 ok

javascript - 匹配多个数组中的值

Javascript 字符计数器重复

javascript - 注入(inject) ngMock 后应用程序崩溃

javascript - 在 Angular 应用程序中使用 HTML 设置 JSON 样式

javascript - 测试 angularjs 指令(更改隔离范围 var 后未在测试中更新模板)

jquery - AngularJs 为 ng-swipe 添加动画

AngularJS 指令 : Are Link and Compile functions meant to work together?

javascript - 为什么我创建一个对象时,控制台说它的原型(prototype)是Object,而JS中是Object.prototype?

angularjs - 预检响应在 AngularJS 中具有无效的 HTTP 状态代码 404