小编kin*_*ohm的帖子

在jasmine测试中没有调用AngularJS指令链接函数

我正在创建一个在其link函数中调用服务的元素指令:

app.directive('depositList', ['depositService', function (depositService) {
    return {
        templateUrl: 'depositList.html',
        restrict: 'E',
        scope: {
            status: '@status',
            title: '@title'
        },
        link: function (scope) {
            scope.depositsInfo = depositService.getDeposits({
                status: scope.status
            });
        }
    };
}]);
Run Code Online (Sandbox Code Playgroud)

这项服务现在很简单:

app.factory('depositService', function(){
  return {
    getDeposits: function(criteria){
      return 'you searched for : ' + criteria.status;
    }
  };
});
Run Code Online (Sandbox Code Playgroud)

我正在尝试编写一个测试,以确保depositService.getDeposits()使用正确的状态值调用.

describe('Testing the directive', function() {
  beforeEach(module('plunker'));
  it('should query for pending deposits', inject(function ($rootScope, $compile, $httpBackend, depositService) {

      spyOn(depositService, 'getDeposits').and.callFake(function(criteria){ 
        return 'blah'; 
      });

      $httpBackend.when('GET', 'depositList.html')
          .respond('<div></div>'); …
Run Code Online (Sandbox Code Playgroud)

javascript jasmine angularjs

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

WPF自定义控件与泛型 - 可能吗?

我想使用泛型创建自定义WPF控件:

public class MyGenericTypeControl<T> : ItemsControl 
{   
   // ...
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?在我最初的实验中,一旦尝试在某处添加此控件,我就会遇到设计时/编译时XAML错误.这并不奇怪,因为构建我的自定义控件需要XAML不提供的其他信息.

有任何想法吗?

c# generics wpf xaml controls

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

仅返回与特定年份匹配的Jekyll帖子

如何循环浏览Jekyll网站的帖子,但只对年份等于特定值的帖子采取行动?

{% for post in site.posts %}
  {% if post.date.year == 2012 %}
      <p>{{ post.date }}</p>
      <p>{{ post.title }}</p>
  {% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

以上不起作用.这样做的正确方法是什么?

liquid jekyll

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

你怎么关闭浏览器应用程序的Silverlight?

我正在运行一个Silverlight 4应用程序,提升了对浏览器的信任,不能依赖DOM或主机网页来关闭Silverlight.没有App.Current.Shutdown()方法.如何以编程方式关闭Silverlight应用程序?

silverlight silverlight-4.0 silverlight-oob

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

不调用Thread.Join()的后果

如果我在C#中启动一个新线程,我可以解雇并忘记,而不必担心线程被加入吗?

void DoSomething()
{
  var worker = new Worker();
  var start = new ThreadStart(worker.DoStuff);
  var thread = new Thread(start);
  thread.Start();

  // do something else...
  // who knows how long it'll take...

  // exit without calling thread.Join()

}
Run Code Online (Sandbox Code Playgroud)

编写此代码会有后果吗?

.net c#

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

angular.js有两个指令,第二个指令不执行

我在angular.js模块中定义了两个指令.首先声明的HTML元素执行其指令,但使用other指令的第二个HTML元素不执行它.

鉴于此HTML:

<div ng-app="myApp">
  <div ng-controller="PlayersCtrl">
    <div primary text="{{primaryText}}"/>
    <div secondary text="{{secondaryText}}"/>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

和这个angular.js代码:

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

function PlayersCtrl($scope) {
    $scope.primaryText = "Players";
    $scope.secondaryText = "the best player list";
}

myApp.directive('primary', function(){
  return {
    scope: {
      text: '@'
    },
    template: '<h1>{{text}}</h1>',
    link: function(scope, element, attrs){
      console.log('primary directive');
    }
  };
});

myApp.directive('secondary', function(){
  return {
    scope: {
      text: '@'
    },
    template: '<h3>{{text}}</h3>',
    link: function(scope, element, attrs){
      console.log('secondary directive');
    }
  };
});
Run Code Online (Sandbox Code Playgroud)

生成的HTML只是"主要"指令,"辅助"指令不呈现:

<div ng-app="myApp" class="ng-scope">
  <div ng-controller="PlayersCtrl" class="ng-scope"> …
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs angularjs-directive

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

VSCode API 检查路径是否存在

在 VSCode 扩展中,如何在不打开或读取文件的情况下检查文件路径是否存在?

我发现的最接近的是vscode.workspace.fs.Readfilevscode.workspace.openTextDocumenthttps://code.visualstudio.com/api/references/vscode-api#FileSystem),但同样,我不想打开或读取文件。有没有办法做到这一点?

visual-studio-code vscode-extensions

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

如何在TFS Build 2010中执行简单的Exec活动

TFS Build 2010与2008完全不同.没​​有"Exec"任务 - 我正在寻找2010年的"活动".有没有办法在TFS Build 2010中执行基本命令行执行?

tfs tfsbuild tfs2010

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

在sails.js应用程序中设置安全cookie

配置sails.js以设置安全cookie的方法是什么?我们使用redis来持久化会话状态.需要sails.js规定的方式(而不是一些Express中间件选项).最终,我希望检查Chrome Cookie视图中的"安全"列以查找应用的Cookie:

在此输入图像描述

在文档中,没有明确提到如何执行此操作:

http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.session.html

有一个ssl配置选项,但部署应用程序ssl: true没有产生所需的结果:

module.exports.session = {
  ...
  ssl: true
  ...
}
Run Code Online (Sandbox Code Playgroud)

ssl选项也没有记录,但我认为它与签名cookie有关.

编辑:在屏幕截图中,我在没有HTTPS的情况下从localhost服务,但是这个应用程序是使用HTTPS从生产服务器提供的,并且观察到相同的行为

javascript cookies redis node.js sails.js

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

如何在ASP.NET MVC控制器中获取Identity PasswordOptions

我想读取MVC PasswordOptions中配置的Identity .我的配置如下:Startup.csControllerPasswordOptions

services.AddIdentity<ApplicationUser, IdentityRole>(config => {
        config.Password.RequireDigit = true;
        config.Password.RequiredLength = 8;
        config.Password.RequireNonAlphanumeric = true;
});
Run Code Online (Sandbox Code Playgroud)

然后RequireDigit,我如何读取应用程序中的某个或其他位置的PasswordLength,和RequireNonAlphanumeric属性Controller

使用ASP.NET Core 1.0.1.

asp.net-mvc asp.net-identity asp.net-core-mvc

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

为WPF按钮创建自定义投影的方法

我将如何为WPF按钮(或边框等)创建下面显示的阴影?投影是"弯曲的",两端较厚,中间较薄.如果可能的话,我想避免使用图像(PNG),但如果这是最好的选择,那就这样吧.是否有办法以某种方式使用渐变来做到这一点?

示例按钮

wpf xaml

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