我一直在努力寻找解决方案.
我有一个具有不同"皮肤"的项目,它们基本上是不同的模板/ Css集合.
我试图让我的组件使用基于变量THEME_DIR的皮肤.
不幸的是,我找不到如何实现这一点.我在angular.io上查看了Dynamic Component Loader但没有成功.
我也在这里看了几个答案但没有成功.
有没有人有想法?
这是我到目前为止所尝试的:
import { ComponentFactoryResolver, ViewContainerRef } from '@angular/core';
// @Component({
// templateUrl: '../../assets/theme/'+THEME_DIR+'/login.template.html',
// })
export class LoginComponent implements, AfterViewInit {
private log = Log.create('LoginPage');
constructor(private mzksLsRequestService: MzkLsRequestService,
private componentFactoryResolver: ComponentFactoryResolver,
public viewContainerRef: ViewContainerRef) {
}
ngAfterViewInit() {
let componentFactory = this.componentFactoryResolver.resolveComponentFactory(new Component({
templateUrl: '../../assets/theme/default/login.template.html',
}));
let viewContainerRef = this.viewContainerRef;
viewContainerRef.clear();
let componentRef = viewContainerRef.createComponent(componentFactory);
}
}
Run Code Online (Sandbox Code Playgroud) 我在 Angular 4 项目中使用 RxJS。
我正在尝试启动一个 Websocket,特别是想知道这个 Websocket 何时打开。
我目前正在使用 RxJS (v5) 的 WebSocket。 https://github.com/ReactiveX/rxjs/blob/master/src/observable/dom/WebSocketSubject.ts
我注意到 WebSocketSubjectConfig 中有一个 openObserver,但我找不到如何创建 Observer。我已经锁定它几个小时了。
这是迄今为止我的代码的摘录:
import { Injectable } from '@angular/core';
import { webSocket} from 'rxjs/observable/dom/webSocket';
import { WebSocketSubject, WebSocketSubjectConfig} from 'rxjs/observable/dom/WebSocketSubject';
@Injectable()
export class MzkWebsocketJsonRpcService {
subject: WebSocketSubject<any>;
jsonRpcId: number;
constructor() {
this.subject = webSocket('ws://localhost:12345');
this.subject.openObserver =
/// Find a way to create the openObserver
this.subject.subscribe(
this.onMessage,
this.onError,
this.onClose,
);
console.log('Socket connected');
this.jsonRpcId = 1;
}
public send(method: string, params: any[]) {
let …
Run Code Online (Sandbox Code Playgroud) 我尝试通过添加以下内容在 gitlab -ci 中使用 elasticsearch 服务:
image: python:3.6
services:
- elasticsearch:2.4
Run Code Online (Sandbox Code Playgroud)
在我的 .gitlab-ci.yml
不幸的是,它似乎不起作用(我无法在http://127.0.0.1:9200/ 上拒绝连接)。任何的想法?
我还尝试使用以下命令启动 docker 映像:
test:
script:
- docker run -d elasticsearch
Run Code Online (Sandbox Code Playgroud)
但是docker
不在场...
我正在创建一个脚本来将 JSON 对象转换为“字符串”文件(用于翻译目的)。这个想法是要转变:
{
"TRANSLATION1": "text1",
"TRANSLATION2": "text2"
}
Run Code Online (Sandbox Code Playgroud)
进入
"TRANSLATION1" = "text1";
"TRANSLATION2" = "text2";
Run Code Online (Sandbox Code Playgroud)
这是用以下方法完成的:
jq -r 'to_entries|map("\"\(.key)\"=\(.value|tojson);")|.[]'
好的!
现在,我的问题是嵌套对象:
{
"TRANSLATION1": "text1",
"TRANSLATION2": "text2",
"TRANSLATION3": {
"SUBTRANS1": "subtranslation1",
"SUBTRANS2": "subtranslation2",
}
}
Run Code Online (Sandbox Code Playgroud)
我想要的结果是:
"TRANSLATION1" = "text1";
"TRANSLATION2" = "text2";
"TRANSLATION3.SUBTRANS1" = "subtranslation1";
"TRANSLATION3.SUBTRANS2" = "subtranslation2";
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?我已经挠头好几个小时了......