小编Epi*_*ine的帖子

使用服务对控制器进行角度单元测试 - 打破注入

我正在为业力编写一个单元测试,无法让它运行.它似乎打破了注入功能.我认为这与我如何在测试中获得控制器有关,但无法找到解决方案.

我刚刚开始使用角度在过去的几天,所以任何建议将不胜感激,谢谢!

错误:

Error: Argument 'fn' is not a function, got string
  at Error (<anonymous>)
  at $a (path/app/lib/angular.js:16:453)
  at qa (path/app/lib/angular.js:17:56)
  at Cb (path/app/lib/angular.js:24:458)
  at Object.d [as invoke] (path/app/lib/angular.js:27:66)
  at path/app/lib/angular.js:26:194
  at Array.forEach (native)
  at m (path/app/lib/angular.js:6:192)
  at e (path/app/lib/angular.js:25:298)
  at Object.sb [as injector] (path/app/lib/angular.js:29:360)
TypeError: Cannot read property 'zip' of undefined
  at null.<anonymous> (path/test/unit/controllersSpec.js:26:19)
Run Code Online (Sandbox Code Playgroud)

测试:

'use strict';

/* jasmine specs for controllers go here */

describe('influences controllers', function() {
  beforeEach(module('influences.controllers', ['ui.bootstrap', 'influences.services']));

  describe('IndividualCtrl', function(){

    var scope, ctrl, service, $httpBackend; …
Run Code Online (Sandbox Code Playgroud)

angularjs

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

在google-apps-script中逐字递增

我在第3-15行的多列中有数据.我想找到该数据集中的所有唯一值,并将其输出到一列.

唯一函数一次只能执行一列,因此不适用于我的目的.

我正在编写一个脚本,它将打开一个新工作表并将值复制并粘贴到同一列中(将来自多个列的数据合并到一个更长的列中).然后,我将在包含所有数据的单个列上运行唯一函数,以获得原始数据集中所有唯一值的输出(Items!B3:Z15)

我已经编写了代码,但无法弄清楚如何增加一个字符.如果有更好的方法来实现这一点,我愿意接受建议,但我也很好奇是否可以增加字母.

感谢您的帮助,这是我目前的代码:

function uniqueIngredients() {

  var book = SpreadsheetApp.getActiveSpreadsheet();
  var r=1;  // starting with row 1 new sheet
  var d='B';
  for (i=1; i<4; i++){  //testing by running 3 iterations
    var m = 'Ingredients!A'+r;  //Intially return Ingredients!A1 then incremented by 11 ex A12
    var c = 'Items!'+d+'4:'+d+'15';  // Initially return Items!B3:B15 then incremented by letter ex Items!C3:C15
    r = r+12;  // add 12 spaces before next copy (max number of ingredients for each item)
    d++;
    book.getRange(c).copyTo(book.getRange(m), {contentsOnly:true});
  } …
Run Code Online (Sandbox Code Playgroud)

google-sheets google-apps-script

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