在 javascript 中,我们可以合并两个对象的属性,如下所示:
const ob1 = { a: 1, b: 2 };
const ob2 = { c: 3, d: 4 };
const ob3 = { ...ob1, ...ob2 }; // { a: 1, b: 2, c: 3, d: 4 }
Run Code Online (Sandbox Code Playgroud)
我们可以在返回数据时在密码查询中执行相同的操作吗?目前我有如下查询:
MATCH (n1:Node1)-[r:RELATION]->(n2:Node2)
RETURN n1{ .*, rel: PROPERTIES(r) }
Run Code Online (Sandbox Code Playgroud)
我想要的是在返回的对象中包含 的所有属性,r而不是添加rel属性。
我有一个带有四个formControls 和只有一个输入字段的 angular 2 反应形式。我想要的是要求用户逐一填写信息。所以,我分配firstControlName到一个属性调用currentFormControlName上ngOnInit,并在模板文件中的输入字段绑定它。当用户填写他的名字时,该字段将有效,提交时我会将currentFormControlName属性更改为下一个 formControlName。但问题是绑定没有更新。输入字段仍然绑定到name。当我在输入字段上输入内容时, 的值name正在更新 not email。
app.component.ts
ngOnInit() {
this.form = this.builder.group({
'name': ['', Validator.required],
'email': ['', Validator.email],
'phone': ['', Validator.required],
'password': ['', Validator.required],
});
this.currentFormControlName = 'name';
}
submit() {
this.currentFormControlName = 'email'; // Setting it manually just for the demo of this question.
}
Run Code Online (Sandbox Code Playgroud)
应用程序组件.html
<form [formGroup]="form">
<input type="text" [formControlName]="currentFormControlName">
<input type="submit" (click)="submit()">
</form>
Run Code Online (Sandbox Code Playgroud)