我的HTML中有一个表格,每行的一个单元格中都有一个输入复选框。
现在,我尝试检查复选框是否已选中,以下是我尝试过的操作。
HTML:
<table class="table table-hover" id="just_a_table">
<thead>
<tr>
<th scope="col">Select</th>
<th scope="col">IP Addr</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of instances">
<td><input type="checkbox" (click)='onSelect()'></td>
<td>{{data["IP"]}}</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
TS:
onSelect() {
// We get the table data from the html and find if the checkbox is active.
// The rows of the tables can be accessed by "rows" object and cells can be accessed using "cells" object.
this.table_data = document.getElementById("just_a_table")
for (var i=1, row; row …Run Code Online (Sandbox Code Playgroud) 我有以下结构的零件清单:
level | description
0 | sfg
1 | sdf
2 | asdisg
3 | sidjhf
4 | wefdsj
4 | asdfg
4 | sgfd
4 | sdg
3 | sfg
3 | fdg
4 | sdfg
4 | sdsfd
4 | sdf
4 | sdf
2 | adf
3 | sdfg
4 | sdg
4 | sdf
4 | sdf
4 | sdf
1 | shfg
2 | ijsd
3 | ijsd
4 | sdf
4 | sdf
Run Code Online (Sandbox Code Playgroud)
我需要将零件列表转换为这样的层次结构文件夹结构(在嵌套JSON中更可取): …
我对服务工作者相当.then()陌生,而且我读过的几乎所有教程/文章都使用过,因为服务工作者大量依赖承诺,但我没有看到任何在与服务工作者合作时使用 async/await 的教程。有什么原因吗?教程是旧的还是我不应该对服务工作者使用异步/等待?
例子:
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
Run Code Online (Sandbox Code Playgroud)
可以使用 async/await 完成吗?
资料来源我看了一下那个用途 .then()
https://developers.google.com/web/fundamentals/primers/service-workers/registration
https://developers.google.com/web/fundamentals/primers/service-workers
https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle
https://developers.google.com/web/fundamentals/codelabs/offline
如何在测试后测试observable是否取消订阅.我正在开发ionic2/angular2.
我希望在Chrome开发人员模式下输入类似的东西,它会返回值:
observableName.isSubscribe()
我想在Angular变得更好,我想知道儿童与父母之间的交流的最佳做法。我当前要使用的应用程序是在Angular 6上运行的。我知道我可以使用@ ViewChild,@ Output或创建服务在父级组件之间进行通信。还有其他沟通方式吗?如果不是,那三者中哪一个更好,为什么?
这是一个简单的例子:
子HTML
<button (click)="onLinkedClicked();">Click me</button>
Run Code Online (Sandbox Code Playgroud)
儿童TS
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
.
.
.
export class showcaseMenuComponent implements OnInit {
@Output() public linkedClicked = new EventEmitter<String>();
constructor() {}
onLinkedClicked() {
console.log('on click child');
this.linkedClicked.emit('collapsed');
}
}
Run Code Online (Sandbox Code Playgroud)
父HTML
<showcase-menu #topNavMenu
[showBranding]="false"
[showSearch]= "false"
(linkedClicked)="linkToggler($event)">.
</showcase-menu>
Run Code Online (Sandbox Code Playgroud)
家长TS
.
.
.
navMenuState: string;
.
.
.
linkToggler($event) {
console.log("partent");
this.navMenuState = $event;
}
Run Code Online (Sandbox Code Playgroud) 我有对象数组
[0: {yplace: 11, xrow: 4}1: {yplace: 12, xrow: 4}2: {yplace: 13, xrow: 4} ]
<div class="row-place" *ngFor="let seat of reservation.seats; let i = index" >
{{seat.xrow}} <input [(ngModel)]="seat.xrow" name="row" type="number" min="0" class="place form-control signup-row">
{{seat.yplace}} <input [(ngModel)]="seat.yplace" name="place" type="number" min="0" class="place form-control signup-row">
</div>
Run Code Online (Sandbox Code Playgroud)
在 html 中,我有 3 个输入,所有输入都只绑定数组中的最后一个元素?
但是当我使用{{seat.xrow}}并且{{seat.yplace}}显示正常时,我预期
如何使用输入标签进行双向数据绑定。每个输入都有来自数组而不是最后一个元素的唯一索引?
编辑:我有
reservation: ReservationAdminDto = {
seats: [],
email: '',
phoneNr: ''
};
Run Code Online (Sandbox Code Playgroud)
ReservationAdminDto.model.ts有一个形式:
export class ReservationAdminDto {
email: string;
phoneNr: string;
seats: SeatDto[]; …Run Code Online (Sandbox Code Playgroud) 我有一个变量,它从我的数据库中获取字符串并将其显示在我的一个面板上。获取的文本包含典型的 HTML 标签,例如<b><u><p>等。
<div [innerHTML]="myVariableWithTags"></div>
Run Code Online (Sandbox Code Playgroud)
这在测试时可以工作ionic lab,但不能在模拟器或真实设备上运行。
所以我的问题是 Ionic 的 innerHTML 的替代品是什么?
例如我的变量myVariableWithTags如下:
<b>This has to be bold</b> <i>and this italic</i>
Run Code Online (Sandbox Code Playgroud)
我想做以下事情:
<div> {{myVariableWithTags}} </div>
Run Code Online (Sandbox Code Playgroud)
并希望看到面板如下所示: 这必须是粗体 ,斜体
代替<b>This has to be bold</b> <i>and this italic</i>
这可能吗?
我知道当一个应用程序有很多部件和组件时,最好将它们分成延迟加载的模块,这样用户就可以快速看到应用程序主页。
问题是我注意到导航到延迟加载模块的组件显示用户交互(单击按钮/菜单)和显示组件时(与非延迟加载组件相比)之间存在一些延迟。
有没有办法手动预加载延迟加载的模块?所以假设用户看到了主屏幕,如果在 3 秒内什么也没做,那么在后台加载我的一些关键应用程序模块。
我是angular的新手,我想知道是否可以加载和基于我在app.module上创建的模块及其组件,或者在哪里是最佳选择
基本上我想做这样的事情:
if(user.deparment === 'coms') {
//Use the communications.module and its components
}
Run Code Online (Sandbox Code Playgroud)
我附上了一些图片,以便你们看到应用程序的结构。如有必要,我可以添加代码而不是图片。
<div class="form-group" [formGroup]="gGroup">
<label for="grouplabel">Group</label>
<select formControlName="groupControl" [(ngModel)]="groupobj" (ngModelChange)="onSelectGroup($event)" id="group" class="form-control">
<option>Select</option>
<option *ngFor="let group of groups" [selected]="current_group === group.name">{{group.name}}</option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
如何在组件中将<select>字段的值设置为“ 动态选择 ”?
我看了看文档https://angular.io/api/forms/FormControlName#use-with-ngmodel,但仍然没有可以帮助我的示例。
尝试:
this.gGroup.get('groupControl').setValue('Select');
angular ×6
angular6 ×2
javascript ×2
innerhtml ×1
json ×1
ngfor ×1
observable ×1
rxjs ×1
typescript ×1
viewchild ×1