小编Fla*_*ape的帖子

TWS Interactive Brokers API-如何解决“未为请求找到安全定义”?

使用Java API(我猜想这适用于任何其他TWS Interactive Brokers客户端API),出现错误“未为请求找到安全定义”。FAQ和其他资源毫无帮助。

    Contract contract = new Contract();

    int id = incId;           

    System.out.println("Oder Id " + id );

    // use UTC seconds as transaction id

    // This is the problem you need to have a blank contractId
    contract.m_conId = 12345;
    contract.m_symbol = signal.symbol;
    contract.m_secType = "STK";
    contract.m_expiry = "";
    contract.m_strike = 0;
    contract.m_exchange = "SMART";
    contract.m_primaryExch = "ISLAND";
    contract.m_currency = "USD";

    //etc

    Order order = new Order();

    // set order fields
    order.m_account = "XXXXXX";
    order.m_orderId = id;
    //etc

    GetInstance().wrapper.m_client.placeOrder(id, …
Run Code Online (Sandbox Code Playgroud)

java api tws interactive-brokers

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

如何定位缺少 $injector 错误?

我正在将一些核心的角度内容移植到一个新项目中。现在我收到注入器错误,但堆栈跟踪/角度错误页面不显示有问题的注入错误的类名。我得到的只是

\n\n
Error: $injector:modulerr\nModule Error\n
Run Code Online (Sandbox Code Playgroud)\n\n

通常那里有一个类名。现在我必须检查每个类(数十个)并手动检查导入。难道就没有更好的办法吗?我在添加类时就看到了这种情况的发生。有时它会显示丢失的注入的名称,有时它只是显示为空白,否则堆栈跟踪会正确识别丢失/错误的注入。

\n\n

是否有一些额外的调试模式可以获取此信息?

\n\n

完整的(无用的)堆栈跟踪:

\n\n
Failed to instantiate module FSApp due to:\nError: [$injector:modulerr] http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=FSApp&p1=Error\xe2\x80\xa6cape%2Fmain%2Fresources%2Flib%2Fangular-1.2.16%2Fangular.min.js%3A32%3A445)\n    at Error (native)\n    at http://fs/main/resources/lib/angular-1.2.16/angular.min.js:6:450\n    at http://fs/main/resources/lib/angular-1.2.16/angular.min.js:33:332\n    at Array.forEach (native)\n    at q (http://fs/main/resources/lib/angular-1.2.16/angular.min.js:7:280)\n    at e (http://fs/main/resources/lib/angular-1.2.16/angular.min.js:32:445)\n    at http://fs/main/resources/lib/angular-1.2.16/angular.min.js:33:18\n    at Array.forEach (native)\n    at q (http://fs/main/resources/lib/angular-1.2.16/angular.min.js:7:280)\n    at e (http://fs/main/resources/lib/angular-1.2.16/angular.min.js:32:445\n
Run Code Online (Sandbox Code Playgroud)\n\n

如果您想尝试重现此情况,请提交您的更改。到处删除几个文件。运行你的角度应用程序。如果删除得足够多,您很快就会收到空白注射器错误。

\n

code-injection angularjs

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

如何使用编译元素在单元测试中访问controllerAs命名空间?

在这个小提琴http://jsfiddle.net/FlavorScape/fp1kktt9/我尝试在控制器上设置属性,而不是直接在$ scope.在模板中(在生产中)我们只做myAliasCtrl.somePropertyList和ng-repeat工作.

但是,这在测试中不起作用.我不知道如何在控制器上获取/分配属性.

更新: 我的测试环境中一定有一些奇怪的本地化问题,因为我确实让ng-repeat工作.注意有两个子元素,即使该属性在别名控制器上.http://jsfiddle.net/FlavorScape/2adn983y/2/

但是,我的问题仍然是,我如何获得对该编译控制器的引用来说,创建一个间谍?(或者只是获得别名控制器的引用)?

这是来源:

angular.module('myApp', [])
.directive('myTestDirective', function () {
    return {
        restrict: 'E',
        scope: {
            myBinding: '='
        },
        replace: true,
        template: '<div ng-if="isRendered">TEST<div ng-repeat="foo in myCtrl.fooList">{{foo}}</div></div>',
        controller: 'myTestController',
        controllerAs: 'myCtrl'
    };
})
.controller('myTestController', function($scope) {
    $scope.isRendered = true;
     // if i reference this, ng-repeat works
    $scope.fooList = ["boob","cat", "Tesla"];
});

describe('myTest directive:', function () {
    var scope, compile, validHTML;

    validHTML = '<div><my-test-directive my-binding="isRendered"></my-test-directive></div>'; //i

    beforeEach(module('myApp'));

    beforeEach(inject(function($compile, $rootScope){
        scope = $rootScope.$new();        
        scope.isRendered = …
Run Code Online (Sandbox Code Playgroud)

unit-testing controller directive angularjs

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

如何在jekyll中填充字符串?

假设我正在递增这样的整数

 {% capture page %}{{ page | plus: '1' }}{% endcapture %}
Run Code Online (Sandbox Code Playgroud)

我怎么能像这样垫?

 {% capture paddedPage %}{{ page | pad '0', 4 }}{% endcapture %}
Run Code Online (Sandbox Code Playgroud)

其中4是填充位置的数量,'0'是填充字符串?最终结果如下所示:0001page的值为1.我如何在内联或过滤器中执行此操作?

我想它可以表示为sprintf('%d4',页面),但显然这种语法不适用于liquid/jekyll.

我对jekyll/liquid语法感到非常失望(甚至没有原始模数!)除此之外,我怎么能填充带有前导字符的字符串?

ruby liquid jekyll

5
推荐指数
2
解决办法
739
查看次数

如何在 Jasmine 单元测试中获取 TypeScript 中“模块”的定义?

所以,这真的很愚蠢。但不可能通过谷歌搜索,因为未定义的模块实际上是module. 我在单元测试中消除了所有其他 TS 错误,除了最后一个错误:

main/components/login/loginController.Spec.ts(12,7):错误 TS2304:找不到名称“模块”。

有些人说,“只需包含 angular-mocks.js”,但我已经这样做了,它消除了其他一些错误,但没有消除这个错误。

这是我的参考资料:

/// <reference path="../../typings/angularjs/angular.d.ts" />
/// <reference path="../../typings/jquery/jquery.d.ts" />
/// <reference path="../../typings/d3/d3.d.ts" />
/// <reference path="../../typings/jasmine/jasmine.d.ts" />
/// <reference path="../../typings/angularjs/angular-mocks.d.ts" />
Run Code Online (Sandbox Code Playgroud)

这是一个说明问题的简单测试。

describe('Login Controller Spec', function() {
    beforeEach(function() {
      // uh oh
      module('App');
      inject(function(_$controller_, $rootScope) {
        scope = $rootScope.$new();
        controller = _$controller_;
        navCtrl = controller('loginController', { $scope: scope});
      });

    });

    it('should call init', function(){
         //...
    });
  });
Run Code Online (Sandbox Code Playgroud)

我应该获得其他任何库的定义吗?

javascript angularjs typescript

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

为什么ng-click不起作用?

为什么这个简单的ng-click示例不起作用?我已经在生产中使用角几个月了,但是这个笨蛋让我感到困惑.

http://plnkr.co/edit/9Rp5JD?p=preview

如果你注意到,ng-show属性正在运行......为什么不是点击?它总是警告默认值而不是角度点击.

<div ng-show="showTest" ng-click="alert('angular click')" onclick="alert('default click')">Default or angular click?</div>
<div ng-show="dontShowMeIsNotDefinedSoIWontShow" >Not showing me, I know angular is working!</div>
Run Code Online (Sandbox Code Playgroud)

没有孤立的范围,根本没有指令......只是一个div.您可以删除onclick ....其他警报永远不会触发.我确定无论问题是什么,我都会变得太近视而无法找到它.

其余的无聊配置:

angular.module('plunker', []);

var app = angular.module('plunker', [
    'plunker'
]);



app.config( function( ) {
        'use strict';
});



app.controller('MainCtrl', function($scope) { 
  var that = this;

  $scope.showTest = true;

});
Run Code Online (Sandbox Code Playgroud)

整个HTML:

<!DOCTYPE html>
<html ng-app="plunker">

<head>
  <meta charset="utf-8" />
  <title>AngularJS Plunker</title>
  <link data-require="bootstrap-css@*" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
  <script>
    document.write('<base href="' + document.location + '" />');
  </script>
  <link rel="stylesheet" …
Run Code Online (Sandbox Code Playgroud)

javascript onclick angularjs

4
推荐指数
2
解决办法
9707
查看次数

如何让Grunt-Contrib-Jasmine执行规范并加载依赖项?

该项目是:Backbone + Require + Underscore + Grunt + Grunt-Contrib-Jasmine + Grunt-Lib-PhantomJS

所以我一直在与两个严重的问题作斗争.我知道phantomjs运行正常等,因为如果我包含我的应用程序src文件,我会遇到大量的运行时错误.我甚至已经正确地命令了deps,以便Backbone不会_被定义等等.

1)当我包含我的应用程序src时,我收到can't find variable: define所有源文件的错误.我已经尝试将需求放入src[]isntead,vendor[]甚至尝试加载一个包含deps的RequireJSConfig.js.

2)这是cruncher:我很确定我正确地指着我的spec文件.如果我只指向一个测试,它仍然说No Specs Executed. Is there a configuration error?在我的情况下,我只是指向我UserModelUnitTest.js,这很简单.它不会执行.我绝对疯了!

Spec(UserModelUnitTest.js):

describe('User Model Unit Tests', function() {
var USER_MODEL,
    USER_CLASS,
    JSON_OBJ;
  beforeEach(function() {
    USER_CLASS = testr('models/user/User', {});
  });

  afterEach(function() {
    USER_MODEL = null;
    USER_CLASS = null;
    JSON_OBJ = null;
  });    
  describe('Given a json object', function() {
    it('should create a valid …
Run Code Online (Sandbox Code Playgroud)

javascript backbone.js jasmine gruntjs grunt-contrib-jasmine

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

有没有办法用grunt-contrib-jasmine输出spec runner?

所以我在PhantomJS中运行了grunt-contrib-jasmine运行规范.有没有办法配置它所以它总是输出_specRunner.html(在浏览器中运行)而不是仅在出错时?

我在doc中看到了这个,但是如何配置这个标志呢?

名称:构建

打开此标志以构建SpecRunner html文件.这在对模板进行故障排除,在浏览器中运行或作为监视链的一部分时非常有用

watch: {
  pivotal : {
    files: ['src/**/*.js', 'specs/**/*.js'],
    tasks: 'jasmine:pivotal:build'
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript jasmine grunt-contrib-jasmine

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

这个角度误差是多少?

刚做了一个简单的控制器注入一些.

var SimpleProductListController = BaseController.extend({

    _notifications:null,
    _productsModel:null,

    init:function($scope,ProductsModel,$route){
    },    
    defineListeners:function(){
        this._super();            
    },
    destroy:function(){

    }
})
/...

SimpleProductListController.$inject = ['$scope','ProductsModel','$route'];
Run Code Online (Sandbox Code Playgroud)

控制台错误指向:http: //errors.angularjs.org/1.2.16/ng/areq?p0 = SimpleProductListController&p1 = not%20aNaNunction%2C%20got%20undefined

Argument 'SimpleProductListController' is not aNaNunction, got undefined
Run Code Online (Sandbox Code Playgroud)

我该如何调试呢?我得到了batarang,但它在这里什么也没做.

javascript arguments angularjs

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

如何从焦点/模糊中更改父元素的类?

我正在尝试在获得焦点时将类添加到输入的父级.我可以得到父母,但我似乎无法设置类名.这是我在这个plunkr尝试的:

http://plnkr.co/edit/eEfSeD​​b7i3uujjBZt21z?p=preview

<!DOCTYPE HTML>
<html id="ng-app" ng-app="app"> <!-- id="ng-app" IE<8 -->

<head>
    <link rel="stylesheet" href="http://nervgh.github.io/css/animate.min.css" />    
    <style>
        .highlight {
          border: 2px solid red;
        }
        .blue-border
        {
          border:2px solid blue;
        }
    </style>

     <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>    
    <script>
        angular.module( 'app', [])
            .run( function( $rootScope, $timeout ) {                   

                 $rootScope.focusInput= function($event )
                {
                    angular.element($event.target).parent().className += " " + 'highlight';
                    console.log( angular.element($event.target).parent() );
                };

                $rootScope.blurInput= function($event )
                {
                    angular.element($event.target).parent().className.replace(' highlight', '');                                       
                };
            });
    </script>

</head>
<body>

    <div class="blue-border">

      <input ng-focus="focusInput($event)" ng-blur="blurInput($event)" value="Lactobacillus acidophilus"/>  

</div>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

请注意它如何成功记录父项.但是,边框不会变红!还有其他更"Angulary"的做法吗?

events focus blur parent angularjs

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