我有以下angular2材料表
<mat-table #table [dataSource]="dataSource" >
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on the row definition" -->
<!-- Position Column -->
<ng-container matColumnDef="selected">
<mat-header-cell *matHeaderCellDef>
<mat-checkbox [(ngModel)]="selectAll"></mat-checkbox>
</mat-header-cell>
<mat-cell *matCellDef="let element">
<mat-checkbox [(ngModel)]="element.selected" [checked]="selectAll"></mat-checkbox>
</mat-cell>
</ng-container>
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef> Id</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.id}}</mat-cell>
</ng-container>
<ng-container matColumnDef="requested_status">
<mat-header-cell *matHeaderCellDef> Status</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.requested_status}}</mat-cell>
</ng-container>
......
Run Code Online (Sandbox Code Playgroud)
我需要通过一些布尔条件隐藏表中的列.是否可以在不改变组件中的列映射的情况下?
displayedColumns = ['selected', 'id', ...];
Run Code Online (Sandbox Code Playgroud)
我尝试使用,*ngIf但它不起作用.怎么做?
我已经对SO进行了一些研究,但类似的Q&A用于检测它是否有连接,但不是关于连接类型.
我的网站的目的是,如果用户在移动设备(手机或平板电脑)和wifi上,播放视频剪辑; 如果用户在移动设备上而不是在wifi上,则播放视频片段; 如果用户不在手机上,则播放视频片段.
不同行为的原因是为了避免由于视频剪辑的相对较大的尺寸而对用户发生可能的附加费.这与速度无关 - 如今LTE与wifi的速度差异可能很小; 更多的是用户担心没有wifi连接的数据使用收费.
所以我的问题是,使用AngularJS(<2.0),1)如何检测设备是桌面还是移动2)如何检测设备是否连接到wifi
(我猜对于Q1,后备是使用Bootstrap @media,但它并不理想.)
我需要在它触发后立即删除wheel事件.我尝试了以下但不删除eventlistener.
export class HomeComponent implements OnInit {
constructor() {}
ngOnInit() {
document.querySelector("#section-one").addEventListener("wheel", () => this.myFunction1(), true);
}
myFunction1() {
alert();
document.querySelector("#section-one").removeEventListener("wheel", this.myFunction1, true);
console.log("Done!");
}
}
Run Code Online (Sandbox Code Playgroud)
有什么建议?