小编jok*_*omo的帖子

如何在指令的单元测试中模拟角度转换过滤器

在我的指令模板中,我需要使用角度平移过滤器:

    <label for="data-source-btn">
      <span id="data-source-btn-span"></span>
      {{'Data Source' | translate}}
    </label>
Run Code Online (Sandbox Code Playgroud)

然后在我对该指令的单元测试中,我收到错误:

未知提供者:translateFilterProvider < - translateFilter

我试过注射$filter并获得$translate$translate = $filter('translate');不解决问题-这是真的用于测试过滤器

我可以注入模块pascalprecht.translate,但这很重要.我如何最好地模拟过滤器?

unit-testing angularjs angular-translate angular-filters

20
推荐指数
1
解决办法
1万
查看次数

未捕获的TypeError:undefined在使用highcharts时不是函数

当我尝试使用简单的highcharts示例时,我收到错误:

Uncaught TypeError: undefined is not a function 
Run Code Online (Sandbox Code Playgroud)

此外 :

TypeError: undefined is not a function
at Object.Ya.init (https://code.highcharts.com/highcharts.js:190:496)
at Object.Ya (https://code.highcharts.com/highcharts.js:15:312)
at HTMLDocument.eval (eval at <anonymous> (https://localhost:3000/bower_components/jquery/dist/jquery.js:330:5), <anonymous>:4:15)
at fire (https://localhost:3000/bower_components/jquery/dist/jquery.js:3073:30)
at Object.self.add [as done] (https://localhost:3000/bower_components/jquery/dist/jquery.js:3119:7)
at jQuery.fn.ready (https://localhost:3000/bower_components/jquery/dist/jquery.js:3352:25)
at jQuery.fn.init (https://localhost:3000/bower_components/jquery/dist/jquery.js:2794:16)
at jQuery (https://localhost:3000/bower_components/jquery/dist/jquery.js:76:10)
at eval (eval at <anonymous> (https://localhost:3000/bower_components/jquery/dist/jquery.js:330:5), <anonymous>:1:1)
Run Code Online (Sandbox Code Playgroud)

我的代码是highcharts网站上的简单示例:

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

<script>
$(function () {

  $('#container').highcharts({
    chart: {
      type: 'bar'
    },
    title: {
      text: 'Fruit Consumption'
    },
    xAxis: {
      categories: ['Apples', 'Bananas', 'Oranges']
    },
    yAxis: …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery highcharts

3
推荐指数
1
解决办法
1万
查看次数