小编Kha*_*led的帖子

如何将过滤器应用于*ngFor?

显然,Angular 2将使用管道而不是Angular1中的过滤器以及ng-for来过滤结果,尽管实现似乎仍然模糊,没有明确的文档.

也就是说,我想要实现的目标可以从以下角度来看待

<div *ng-for="#item of itemsList" *ng-if="conditon(item)"></div>
Run Code Online (Sandbox Code Playgroud)

如何使用管道实现?

typescript angular

237
推荐指数
12
解决办法
30万
查看次数

拉伸子div高度以填充具有动态高度的父级

正如在下面的小提琴中可以看到的那样,我有两个divs,包含在父母中div,已经伸展到包含大div,我的目标是让这些孩子div的身高相等.

http://fiddle.jshell.net/y9bM4/

html css css3

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

如何在悬停后将鼠标移出动画

因此,可以在鼠标输出上进行反向动画,例如:

.class{
   transform: rotate(0deg);

}
.class:hover{
   transform: rotate(360deg);
}
Run Code Online (Sandbox Code Playgroud)

但是,当使用@keyframes动画时,我无法让它工作,例如:

.class{
   animation-name: out;
   animation-duration:2s;

}
.class:hover{
   animation-name: in;
   animation-duration:5s;
   animation-iteration-count:infinite;

}
@keyframe in{
    to {transform: rotate(360deg);}
}

@keyframe out{
    to {transform: rotate(0deg);}
}
Run Code Online (Sandbox Code Playgroud)

什么是最佳解决方案,知道我需要迭代和动画本身?

http://jsfiddle.net/khalednabil/eWzBm/

css animation css3

81
推荐指数
6
解决办法
12万
查看次数

Angular2:子组件访问父类变量/函数

我在父组件中有一个可能由child更改的变量,parent将在视图中使用此变量,因此必须传播更改.

import {Component, View} from 'angular2/core';

@Component({selector: 'parent'})
@View({
    directives: [Child],
    template: `<childcomp></childcomp>`
})
class Parent {
    public sharedList = new Array();
    constructor() {
    }
}


@Component({selector: 'child'})
@View({template: `...`})
class Child {
    constructor() {
        //access 'sharedList' from parent and set values
        sharedList.push("1");
        sharedList.push("2");
        sharedList.push("3");
        sharedList.push("4");
    }
}
Run Code Online (Sandbox Code Playgroud)

angular

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

Angular2,如果未选中复选框,则禁用按钮

我有多个复选框和一个按钮,只有在选中至少一个复选框时才需要启用该按钮

<input type="checkbox">VALUE1
<input type="checkbox">VALUE2
<input type="checkbox">VALUE3
<input type="checkbox">VALUE4
<button>Proceed</button>
Run Code Online (Sandbox Code Playgroud)

如何使用Angular2实现这一目标.

PS:发现了类似的问题,但没有使用Angular2.

checkbox angular

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

jquery表单验证在页面中使用选项卡不起作用

所以基本上我有一个简单的POST表单,使用来自jquery的Validate库进行验证,一切正常,但后来我使用了bootstrap中的tabs功能和许多其他库将表单分成两个不同的选项卡.现在的问题是验证只发生在打开(可见)选项卡上,无论隐藏选项卡中其他输入字段的条件如何.任何可能的建议?

validation jquery tabs twitter-bootstrap

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

如何使用调用该函数的元素的"this"引用?

例如,我想要一个由许多元素用来获取调用元素属性的函数.

function example(){
    var name = //name of the calling element "$(this).attr('name')"
}
<button name="somename1" onclick="example()">Button1</button>
<button name="somename2" onclick="example()">Button2</button>
Run Code Online (Sandbox Code Playgroud)

因此,如果名为"somename1"的按钮调用该函数,则变量"name"将被分配给"somename1",因此如果"somename2"调用它,它将被分配给"somename2"

javascript jquery reference this

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

使用 react-intersection-observer 开玩笑测试反应组件

我正在尝试测试具有包含 react-intersection-observer 的子组件的组件,但我总是收到错误消息

我尝试导入库,但仍然失败。这是最初的测试

    beforeEach(() => {
      testContainer = document.createElement("div");
      document.body.appendChild(testContainer);
      subject = memoize(() =>
        mount(<FilterNav {...props} />, { attachTo: testContainer })
      );
    });

    afterEach(() => {
      testContainer.remove();
    });

    context("the main filter is shown initially", () => {
      it("sets focus on the primary filter", () => {
        subject();
        const input = testContainer.querySelector(".main-input");
        expect(document.activeElement).toEqual(input);
      });
Run Code Online (Sandbox Code Playgroud)

我收到此错误 -> 未捕获 [ReferenceError: IntersectionObserver is not defined]

有没有办法模拟 IntersectionObserver?

谢谢

javascript reactjs jestjs

9
推荐指数
6
解决办法
6422
查看次数

Kubernetes 部署、Pod 和容器概念

我最近开始熟悉 Kubernetes,然而,虽然我确实了解了这个概念,但我还是有一些问题无法通过 Kubernetes 的概念文档清楚地回答,以及一些我希望确认的理解。

  • 部署是部署在Pod中的一组一个或多个容器映像(Docker 等),并通过 Kubernetes 部署控制器监视和创建、更新或删除此类部署。

  • Pod是一组一个或多个容器,这些容器是来自同一个 Deployment,还是可以来自多个 Deployment?

  • “pod 模型包含一个或多个相对紧密耦合的应用程序容器”。关于何时在同一个 Pod 中部署容器而不是单独的 Pod 是否有任何明确的标准?

  • “Pod 是可在 Kubernetes 中创建和管理的最小可部署计算单元” - Pod、Kuberenets 文档。这是否意味着 Kubernetes API 无法(至少直接)监控和管理容器?

感谢您的意见。

deployment docker kubernetes kubernetes-pod

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

更新 Docker 镜像中的 npm

我正在构建 Node.js Docker 映像:docker build . -t imagename,但是我不断收到有关 npm 版本的警告

npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
npm WARN deprecated latest stable version. To upgrade to npm@2, run:
npm WARN deprecated 
npm WARN deprecated   npm -g install npm@latest-2
npm WARN deprecated 
npm WARN deprecated To upgrade to the …
Run Code Online (Sandbox Code Playgroud)

node.js npm docker

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