我从一个架构中筛选出 2 个元素,并希望在另一个架构中更新。为此,我使用 slice 方法从数组中列出前 2 个元素。但我得到
CoreMongooseArray ['element1','element2']
而不是 ["element1", "element2"]
如何删除“CoreMongooseArray”?
connection.connectedusers.find({}, async (err, docs) => {
if(err) throw err;
var users = docs[0].connectArray;
if (docs[0] != null && users.length >= 2) {
var shortListed = users.slice(0, 2);
try {
await connection.chatschema.updateMany({}, { $push: { usersConnected: [shortListed] } }, { upsert: true });
} catch (err) {
res.status(201).json(err);
}
}
Run Code Online (Sandbox Code Playgroud) 我想在用户选择时获取所有复选框项目,现在正在获取数据但问题是复选框不会改变,我的意思是当我单击复选框时,如果选中了初始状态,则始终保持选中状态,反之亦然反之。
this.settings_data = ["one", "two", "three", "four", "five"];
<div class="settings_head" fxFlex="50" *ngFor="let item of settings_data">
<mat-checkbox formControlName="settingsCheckboxvalues" (ngModelChange)="seleteditems($event,item)">{{item}}</mat-checkbox>
</div>
seleteditems(event, value) {
this.allitems.push(value);
}
Run Code Online (Sandbox Code Playgroud) 按下Tab键时如何选择垫选项?它的工作方式应类似于垫自动完成角度6中的Enter键。
<mat-form-field class="example-full-width">
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let option of options" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
javascript material-design angular-material angular-material2 angular