Home  >  Q&A  >  body text

angular.js - 如何使用Angular Chart

我是使用yeoman自动生成的angularjs框架,想在自己的单页面应用中加入图表元素,在网上搜到一个解决方案:angular-chart.js(http://jtblin.github.io/angular-chart.js/)。
跟随着教程一步一步来,到了
angular.module('myModule', ['chart.js']);
这一步卡住了,当我在对应的controller中这样写后,重新运行应用,发现页面上内容消失了,即ng-view的p块内没有内容了,但是console栏并没有报错。我也尝试了把['chart.js']写在app.js中,同样没有效果。
经调试发现,重新运行应用后,查看对应controller的scope发现,scope内的变量labels、data等都是undefine,代码根本没有运行到对应controller内去。

滿天的星座滿天的星座2714 days ago528

reply all(3)I'll reply

  • 世界只因有你

    世界只因有你2017-05-15 17:08:16

    Put the 'chart.js' dependency in app.js

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:08:16

    First check if all your files are imported, like Chart.js,angular-chart.js. I tried it myself and it works.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:08:16

    I am also encountering this problem now, have you solved it?

    reply
    0
  • Cancelreply