VS Code 中是否有任何方法可以更改文件名,以便将文件历史记录保留在 git 中,并且不会认为跟踪的文件已被删除?
我希望命令的 GUI 实现:
git mv oldName.abc newName.xyz
Run Code Online (Sandbox Code Playgroud)
谢谢
我刚刚更新到 Angular CLI 12.0.0,使用 Node 14.17.0 和 npm 7.13.0
\n当我尝试将 Angular Fire 添加到我的项目中时
\nng add @angular/fire\nRun Code Online (Sandbox Code Playgroud)\n我收到消息:
\n\n\n将安装并执行包 @angular/fire@0.0.0。\n您想继续吗?是\n\xe2\x9c\x94 程序包已成功安装。\n您尝试添加的程序包不支持原理图。您可以尝试使用不同版本的包或联系包作者以添加 ng-add 支持。
\n
使用npm uninstall @angular/fire没有帮助。
任何帮助表示赞赏!
\n注意:正如 @deelde 下面提到的,这是一个新的已知错误,因此目前我已恢复到 Angular CLI v11.2.13,并且它正在工作。
\n卸载:
\nnpm uninstall -g @angular/cli\nnpm cache clean --force\nRun Code Online (Sandbox Code Playgroud)\n为了确保卸载有效,这应该会出现错误:
\nng --version\nRun Code Online (Sandbox Code Playgroud)\n重新安装 Angular CLI v11
\nnpm install -g @angular/cli@11.2.13\nRun Code Online (Sandbox Code Playgroud)\n 如何使用 Python 动态指向 MongoDB 中的特定集合名称?
我从网络中的几十个传感器中的任意一个接收数据,并且我想将原始数据存储到以传感器命名的数据库集合中。
# Server Parameters
host = '1.2.3.4'
port = 27017
client = MongoClient(host, port)
db = client.myDB # use database myDB
# receive data from sensors
# {"sensorName":"...", "x":"...", "y":"...", "z":"...", "time":"..."}
db.SensorA.insert_one({...}) # record raw data in the collection for SensorA
db.SensorB.insert_one({...})
db.SensorC.insert_one({...})
Run Code Online (Sandbox Code Playgroud)
我不想明确地写db.SensorName.insert_one({...}),而是想以某种方式引用给定的传感器/集合名称。
谢谢
我想每当我的 Firebase 文档数据发生变化时只调用一次函数,但是将 .subscribe ()链接到我的valueChanges()上会导致订阅在每次更新时触发两次。
无需订阅的基本代码:
home.component.ts:
constructor(private firestore: AngularFirestore) { }
ngOnInit(): void {
let docName = this.buildDocName();
this.plants = this.firestore.collection('officePlants').doc(docName).valueChanges();
}
Run Code Online (Sandbox Code Playgroud)
home.component.html:
<mat-list *ngIf="(plants | async)">
<mat-list-item>Humidity: {{ (plants | async)?.humidity }}</mat-list-item>
<mat-list-item>Temperature: {{ (plants | async)?.temperature }}</mat-list-item>
</mat-list>
Run Code Online (Sandbox Code Playgroud)
此代码导致订阅触发两次:
home.component.ts:
ngOnInit(): void {
let docName = this.buildDocName();
this.plants = this.firestore.collection('officePlants').doc(docName).valueChanges()
.subscribe(data => {
if (!data)
return;
console.log('doc updated...', data);
// ...
});
}
Run Code Online (Sandbox Code Playgroud) rxjs firebase google-cloud-platform angular google-cloud-firestore
我有一组语言供用户选择,还有一种默认语言可供选择。选择默认语言后,我想确保以编程方式选中该语言的复选框。
我不确定如何在语言的 FormArray 上使用 patchValue。
组件.ts
import { FormGroup, FormControl, FormArray, Validators } from '@angular/forms';
...
constructor(...) {
this.languages = ['English', 'Spanish', 'Mandarin', 'Klingon'];
this.myForm = new FormGroup({
languages: this.createLanguagesControl(),
defaultLanguage: new FormControl('', Validators.required)
});
}
createLanguagesControl() {
const controls = this.languages.map(language => {
return new FormControl(false);
});
return new FormArray(controls);
}
defaultLanguageSelection() {
let formValues = this.myForm.value;
console.log('defaultLanguageSelection', formValues.defaultLanguage);
let i = 0;
for (let language of this.languages) {
if (language == formValues.defaultLanguage) { // find the index of …Run Code Online (Sandbox Code Playgroud) formbuilder angular angular-reactive-forms angular-forms formarray
angular ×3
firebase ×2
collections ×1
formarray ×1
formbuilder ×1
git ×1
mongodb ×1
npm ×1
python ×1
reflection ×1
rxjs ×1