小编Hel*_*rld的帖子

将$ state或$ stateParams注入到使用angular ui路由器不可能的指令中

当我将$ state/$ stateParams注入指令时,它们在unique函数中不可用,为什么?

'use strict';
angular.module('TGB').directive('uniqueSchoolclassnumberValidator', function (schoolclassCodeService) {
    return {
        restrict: 'A',
        require: 'ngModel',
        link: function (scope, element, attrs, ngModel) {
            ngModel.$asyncValidators.unique = function (schoolclassNumer) {

                var schoolyearId = 1; // Read schoolyearId from the $stateParams.id but how to inject?
                return schoolclassCodeService.exists(schoolyearId, schoolclassNumber);
            };
        }
    };
});
Run Code Online (Sandbox Code Playgroud)

UPDATE

在此输入图像描述

正如您在我的谷歌Chrome控制台中看到的,$ stateParams或$ state未定义!

angularjs angular-ui-router

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

ormlite servicestack中的枚举和标志支持

由于我的错误消息:

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code

Additional information: Conversion failed when converting the nvarchar value 'AB' to data type int.
Run Code Online (Sandbox Code Playgroud)

我有一个带有AB值的枚举,我想将其保存为整数而不是nvarchar值.我有一个带有flags属性的枚举类似于:[Flags]

public enum VisibleDayOfWeek : int
{
    None = 0,
    Monday = 1,
    Tuesday = 2,
    Wednesday = 4,
    Thursday = 8,
    Friday = 16,
    Saturday = 32,
    Sunday = 64
}
Run Code Online (Sandbox Code Playgroud)

我无法在数据库中保存多天字符串,但我可以保存代表多天的标志值的总和.

我不想在这些枚举属性周围创建一个整数包装器.

枚举的基础类型是字节或整数,那么为什么它保存为字符串/ varchar?这是没有意义的.甚至实体框架在多年后的枚举支持下也是正确的......

这种情况下的解决方案是什么?

似乎这家伙有同样的问题:https://github.com/tapmantwo/enumflags

servicestack ormlite-servicestack

7
推荐指数
2
解决办法
1975
查看次数

确定包含项目的对齐顺序

这是我的代码:http://codepen.io/helloworld/pen/JoKmQr

让我们假设我从服务器获得了一组数据.数据有标题和订单号.

我有5个数组项,orderNumber从1到5.

现在我想布局5个div,其中每个div位于包装布局系统中的某个位置.

看这个图片:

在此输入图像描述

颜色并不重要.重要的是div的顺序根据他们的订单号.

把orderNumber的流动从去.

问题:

如何确定布局系统中div的顺序?他们自动布局到我想要的流程?或者手动订购的提示也没关系:-)

HTML

<h1>Packery demo - Draggabilly</h1>
<div class="packery js-packery" data-packery-options='{ "isHorizontal": true }'>
  <div class="item w1"></div>
  <div class="item h4"></div>
  <div class="item w2"></div>
  <div class="item w3"></div>
  <div class="item h2"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

* {
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
}

body { font-family: sans-serif; }

.packery {
  background: #FDD;
  background: hsla(45, 100%, 40%, 0.2);
  counter-reset: item;
  height: 400px;
}

/* clearfix */ …
Run Code Online (Sandbox Code Playgroud)

jquery packery

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

使angularJS ui路由器与角度材料设计TABS一起使用

应用程序启动时TabControl可见但是......

当我点击标签时,没有内容可见

我错了什么?

我使用最新的angularJS材料设计0.9.4.

   $urlRouterProvider.otherwise("");
      $stateProvider

          .state("main",
          {
            abtract: true,
            url: '',
            views: {
              'content@': {
                templateUrl: '../app/views/administration/administration.html',
                controller: 'AdministrationController'
              }
            }
          })
          .state('main.settings', {
            url: '/settings',
            views: {
              'settings@main': {
                templateUrl: "../app/views/administration/settings.html",
                controller: 'GlobalConfigurationController'
              }
            }
          })
          .state('main.schoolyears', {
            url: '/schoolyears',
            views: {
              'schoolyears@main': {
                templateUrl: "../app/views/schoolyear/schoolyears.html",
                controller: 'SchoolyearsController'
              }
            }
          });
Run Code Online (Sandbox Code Playgroud)

HTML

<div layout-fill layout="column">
  <div ng-include="'app/components/navbar/navbar.html'"></div>
  <div id="content" layout="column" layout-padding>

    <md-tabs md-stretch-tabs="always" class="md-primary md-hue-2">

      <md-tab label="Schoolyears" ui-sref="main.schoolyears" md-active="$state.is('main.schoolyears')">
        <md-tab-body ui-view="schoolyears" layout="vertical" layout-fill></md-tab-body>
      </md-tab>

      <md-tab label="settings" ui-sref="main.settings" md-active="$state.is('main.settings')"> …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-router material-design

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

如何在.NET中进行极端的品牌/国际化

我们正计划一个非常大的应用程序.

- 我们希望将我们的应用程序国际化到30个国家.

- 在大多数国家,有1到6个不同的品牌可供选择.

- 像'de'这样的某个区域设置和像'XXX'这样的品牌的每个组合可能会多次出现,因此我们需要另一个标识符来获取独特的内容:

"locale_brand_siteorigin"
Run Code Online (Sandbox Code Playgroud)

因此我们有.resx文件,如:

配置.de.burgerking.px10 .resx

粗体打印是唯一标识符.

在运行时我们创建一个:

var rm = new ResourceManager("MyNamespace.Configurations.UniqueIdentifier",Assembly.GetExecuting());
Run Code Online (Sandbox Code Playgroud)

根据我们的业务逻辑,我们可以创建上面的resourceManager.

最后,我们将最终拥有180多个resx文件,其中包含唯一标识符的所有组合.

你知道更好的方法来做这种品牌吗?

4年前有人问过这个问题,但没有人回答:

实施应用程序品牌的行业标准?

UPDATE

我还想扩展我的问题,要求提供一个解决方案,展示使用cultureandregioninfobuilder类创建那些许多自定义文化的好处.

https://msdn.microsoft.com/en-us/library/system.globalization.cultureandregioninfobuilder(v=vs.110).aspx

c# branding internationalization asp.net-mvc-5.2 .net-4.6.1

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

单元测试自定义knockoutjs绑定

我怎样才能测试这个knockoutjs绑定,当我在触摸板上刷一个元素时,我调用某个函数'myValueAccessor'?

我也不确定该单位应该或能够在这里测试什么.

第一次断言myValueAccessor被调用就没问题了.

但是我怎么能触发/模仿或者我应该说嘲笑... swiperight事件?

ko.bindingHandlers.tap = {
    'init': function (element, valueAccessor) {
        var value = valueAccessor();    

        var hammertime1 = Hammer(element).on("swiperight", function (event) {
            $(element).fadeOut('fast', function () {
                value();
            });
        });
    }
};

 self.myValueAccessor = function () {
    location.href = 'set a new url'
};
Run Code Online (Sandbox Code Playgroud)

UPDATE

我已经在这里用mocha.js进行了我的单元测试

我可以在绑定中取消'value()',但测试成功仍然是奇怪的.

这个(作为测试)是不正确的:

function (element,args) {
                    alert('assertion here');
                }
Run Code Online (Sandbox Code Playgroud)

作为ko.test函数的第3个参数?

  ko.bindingHandlers.tap = {
                    'init': function (element, valueAccessor) {
                        var value = valueAccessor();

                        var hammertime1 = $(element).on("swiperight", function (event) {
                            $(element).fadeOut('fast', function () {
                                //value(); …
Run Code Online (Sandbox Code Playgroud)

unit-testing knockout.js

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

我什么时候应该在Web api中使用HttpRequestMessage作为参数

我什么时候使用第一个动作?

public HttpResponseMessage Put(HttpRequestMessage message)
{

}
Run Code Online (Sandbox Code Playgroud)

我几乎总是只看到这种方式.也许是因为它很容易映射到一个完整的网址?

public HttpResponseMessage Put(int id)
{

}
Run Code Online (Sandbox Code Playgroud)

asp.net-web-api

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

asp.net scriptbundle多个include vs single include

捆绑有什么区别:

  bundles.Add(new ScriptBundle("~/bundles/jquery")
  .Include("~/Scripts/jquery-{version}.js","file2.js", "file3.js"));
Run Code Online (Sandbox Code Playgroud)

VS

   bundles.Add(new ScriptBundle("~/bundles/jquery")
                .Include("~/Scripts/jquery-{version}.js")
                .Include("file2.js")
                .Include("file3.js"));
Run Code Online (Sandbox Code Playgroud)

我可以在ONE include方法中放入许多脚本,或者我可以使用许多include方法.

我什么时候应该用什么?

asp.net bundling-and-minification scriptbundle

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

命令xcopy ...在Visual Studio中以代码9009退出

当我用10个项目构建解决方案时,我遇到了7个项目的构建失败。所有10个项目都有建后活动。即使是那些构建者,也使用xcopy命令。我之所以这样说是因为我的同事对VS 2012持意见,而xcopy并不是那么好...

这7个构建失败以前从未发生过。

当我尝试构建项目时或在启动Visual Studio时“不时”发生以下错误。

我收到此错误:

Error   1   The command "xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Client" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\Client\" /s /e /v
xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Content" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\Content\" /s /e /v
xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Views" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\Views\" /s /e /v

xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\web.config" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\"
xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\global.asax" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\"

xcopy /y "D:\Replaced\branches\ReplacedTest\Swan.Replaced.Mobile.Web\Tools" "D:\Replaced\branches\ReplacedTest\build\web\bin\..\..\Tools\" /s /e /v
" exited with code 9009.    Swan.Replaced.Mobile.Web
Run Code Online (Sandbox Code Playgroud)

我在Google上搜索了很多,导致此问题的主要原因似乎是:

1.) A whitespace in the path/folder name
2.) The command does not get full paths
3.) Maybe some environment/system variables problem?
Run Code Online (Sandbox Code Playgroud)

我在构建后事件中看不到此错误:

xcopy /y "$(ProjectDir)Client" "$(TargetDir)..\Client\" /s …
Run Code Online (Sandbox Code Playgroud)

build build-error post-build-event visual-studio-2012

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

Flexbox布局在Internet Explorer 10中不起作用

http://jsfiddle.net/J8rL7/87/

根据http://caniuse.com/#feat=flexbox

它应该适用于带有vendor-prefix的IE10.

但事实并非如此!

更新:我刚刚检查了最新的Firefox它看起来完全坏了.

为什么?

<div id="wrapper" style="margin:auto;background-color:yellow;height:100%;">
    <div style="width:50px;height:100%;">
        <div class="fluid-column" style="height:80%;background-color:green;">
            <div class="box" style="background-color:#ff99cc;height:25%;">1</div>
            <div class="box" style="background-color:#ff33cc;height:50%;">2</div>
            <div class="box" style="background-color:#ff66cc;height:25%;">3</div> 
        </div>   
        <div class="fix-column" style="height:20%;background-color:violet">
            <div class="box" style="background-color:orange;height:50%;">Total</div>
            <div class="box" style="background-color:blue;height:50%;">Test</div>
        </div>
    </div>
</div>

body, html{
    width:100%;
    height:100%;
    margin:0;
    padding:0;
}

div{
    text-align:center;
   }

.box
{
    display:-webkit-box;-webkit-box-pack:center;-webkit-box-align:center;
    display:-ms-box;-ms-box-pack:center;-ms-box-align:center;
    display:-moz-box;-moz-box-pack:center;-moz-box-align:center;
}
Run Code Online (Sandbox Code Playgroud)

html css flexbox internet-explorer-10

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