" TypeError:无法读取属性'默认值'未定义"在jqcloud

时间:2016-04-18 11:36:01

标签: 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文件,我只添加了包装器。 现在,我没有收到错误,但我得到一个空白页。

1 个答案:

答案 0 :(得分:0)

您使用过#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.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);
});