确定javascript对象中的所有属性是空还是空字符串的最优雅方法是什么?它应该适用于任意数量的属性.
{'a':null, 'b':''} //should return true for this object
{'a':1, 'b':''} //should return false for this object
{'a':0, 'b':1} //should return false
{'a':'', 'b':''} //should return true
Run Code Online (Sandbox Code Playgroud) 我正在开发一个显示数据表中实体概述的应用程序。每个实体都有链接的实体,在列中显示为“xxx 个链接的实体”。当用户单击该列的值时,将打开一个显示链接实体列表的材料对话框。这些都是与其他实体的链接。单击这些链接之一后,将显示实体的正确页面,但该对话框不会关闭。使用后退按钮时我确实关闭了。我正在使用该closeOnNavigation
物业。
一些示例代码:
在我的主要组件中:
public openDialog(entity: Entity) {
const dialogRef = this.dialog.open(EntityDialogComponent, {
closeOnNavigation: true,
data: {
entity,
otherEntities: this.getNameOfOtherEntities(),
},
});
}
Run Code Online (Sandbox Code Playgroud)
对话框的HTML:
<h1 mat-dialog-title>Linked {{otherEntities}}:</h1>
<mat-dialog-content>
<mat-list role="list">
<mat-list-item role="listitem" *ngFor="let linkedEntity of entity.getProperty('linkedEntities')">
<a class="m-link m--font-bold" [routerLink]="['/reporting/' + otherEntities, linkedEntity.id]">{{linkedEntity.name}}</a>
</mat-list-item>
</mat-list>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button (click)="cancel()">Close</button>
</mat-dialog-actions>
Run Code Online (Sandbox Code Playgroud)
对话框组件:
@Component({
selector: "entity-dialog",
templateUrl: "entity-dialog.component.html",
})
export class EntityDialogComponent {
public entity: Entity;
public otherEntities: string;
constructor(
public dialogRef: MatDialogRef<EntityDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: IDialogData,
) { …
Run Code Online (Sandbox Code Playgroud) 对于我的项目,我们通过 LinkedIn 在主网站上分享一篇文章。LinkedIn说它的阅读时间只有一分钟,而文章的内容却相当大。
我们的第一个猜测是 LinkedIn 根据 cookie 弹出窗口计算读取时间,cookie 弹出窗口总是显示 GDPR 明智的。
有人知道是否可能是这种情况,如果是这样,是否有办法绕过弹出窗口,或在 OG 标签中设置读取时间或其他什么?
亲切的问候, 贝尔廷