我的lodash代码中有一个非常奇怪的问题
我有类似的东西
data = {
'id':'123',
'employee_name': 'John',
'employee_type': 'new'
}
var newObj = _.mapValues(data, function (value, key) {
var t = _.camelCase(key);
console.log(t) -> shows employeeName and employeeType
return _.camelCase(key);
});
Run Code Online (Sandbox Code Playgroud)
我期待着我的newObj会成为
data = {
'id':'123',
'employeeName': 'John',
'employeeType': 'new'
}
Run Code Online (Sandbox Code Playgroud)
在我运行上面的代码之后,它仍然保持不变
data = {
'id':'123',
'employee_name': 'John',
'employee_type': 'new'
}
Run Code Online (Sandbox Code Playgroud)
这太奇怪了,我不知道出了什么问题.有人可以帮我这个吗?非常感谢!
我试图以编程方式触发文档.
我的test-comp显示在页面的多个位置,我想在单击test-comp或触发文档单击时将它们全部隐藏起来.
@Component({
selector: 'test-comp',
template: `<div *ngIf="showMe">stuff</div> and more…`
})
export class TestComponent {
showMenu: boolean;
constructor(public elementRef: ElementRef) {
}
@HostListener('document:click', ['$event'])
documentClick(event: MouseEvent) {
//hide my component when there is a document click
this.toggleComponent();
}
toggleComponent() {
// I am trying to programmatically fire a document click here to hide all test-comp if the test-comp
// component itself is clicked
// this.elementRef.nativeElement will select all test-comp component but not sure what to do next
this.showMe = !this.showMe; …Run Code Online (Sandbox Code Playgroud) 我正在关注这篇文章来运行sql脚本来创建默认表.
这是我的docker撰写文件
version: "3"
services:
web:
build: .
volumes:
- ./:/usr/src/app/
- /usr/src/app/node_modules
ports:
- “3000:3000”
depends_on:
- postgres
postgres:
container_name: postgres
build:
context: .
dockerfile: pgDockerfile
environment:
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
Run Code Online (Sandbox Code Playgroud)
这是我的pgDockerfile
FROM postgres:9.6-alpine
# copy init sql
ADD 00-initial.sql /docker-entrypoint-initdb.d/
Run Code Online (Sandbox Code Playgroud)
这是我的sql脚本
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE IF NOT EXISTS test (
id text NOT NULL,
title varchar(200) NOT NULL
);
Run Code Online (Sandbox Code Playgroud)
我可以构建和运行docker-compose up,我看到以下消息:
postgres | CREATE DATABASE
postgres |
postgres | …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的节点应用程序运行mocha单元测试.该应用程序由docker镜像构建.
Docker镜像:
FROM node:6.10.0-alpine
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
EXPOSE 3000
CMD ["npm", "start"]
Run Code Online (Sandbox Code Playgroud)
Docker撰写:
version: "3"
services:
web: #### nodejs image
build: .
volumes:
- ./app/
ports:
- "3000:3000"
depends_on:
- db
db:
build: ##### postgres db image
context: .
dockerfile: dbDockerfile
ports:
- 5432:5432
Run Code Online (Sandbox Code Playgroud)
可以按预期构建和工作设置.问题不是我确定如何运行单元测试命令mocha来执行测试.
我看到一个名为的模块,dockunit但我不确定这是否是目前唯一的方法.任何人都可以帮我解决这个问题吗?
我正在尝试将旧的 angular 1.5 服务注入到我的 angular 1.5/4 混合应用程序中的 angular 4 模块中。
的MyService,因为如果我让一个市民,我也没办法与初次它使用一个静态方法
new MyService(),因为MyService预计设置了一个param,我不知道如何提供。
我的班级 (my-service.class.ts)
import {Inject, Injectable} from '@angular/core';
@Injectable()
class MyService {
constructor(
@Inject('myOldService') private myOldService: any) {}
static getMyUrl() {
console.log(this.myOldService);
// complains
// Property 'myOldService' does not exist on type 'typeof MyService
return this.myOldService.getItemUrl();
}
}
export default MyService;
Run Code Online (Sandbox Code Playgroud)
我的模块
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
...other import..
import MyService from './my-service.class';
console.log(MyService.getMyUrl())
//has error …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的angular创建一个docker容器,其中包含php文件。Angular需要npm,所以我需要安装nodejs。我不需要为我的项目使用Apache,只需纯PHP即可正常工作。
我的理解是我应该有一个
FROM node:latest
..install php here
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm install
COPY . /usr/src/app
Run Code Online (Sandbox Code Playgroud)
我不确定如何安装php,有人可以指出正确的方向吗?非常感谢!
docker ×3
node.js ×3
angular ×2
javascript ×2
dom-events ×1
lodash ×1
mocha.js ×1
php ×1
postgresql ×1
typescript ×1
unit-testing ×1