我尝试在我的角度6项目中导入rxjs计时器
import { timer } from 'rxjs/observable/timer';
Run Code Online (Sandbox Code Playgroud)
我也尝试过,
Rx.Observable.timer(200, 100)
Run Code Online (Sandbox Code Playgroud)
它们不起作用
这是关于plunker的代码
我已经以一种形式多次实现了相同的组件。我必须将数据从父组件发送到子组件。我知道可以通过@input或viewchild来实现。一个使用另一个的性能问题是什么?我什么时候应该使用viewchild或input?
我可以通过编程方式单击带有 elementref 的按钮元素,但如果按钮是材质按钮,则它不起作用
@ViewChild('findButton') findButton: ElementRef;
clicked() {
console.log('clicked');
}
ngOnInit() {
this.findButton.nativeElement.click()
}
Run Code Online (Sandbox Code Playgroud)
并在模板中,
<div class="example-button-row">
<button #findButton (click)="clicked()" mat-raised-button color="primary">Primary</button>
</div>
Run Code Online (Sandbox Code Playgroud)
mat-raised-button 属性造成了这个问题。这是stackblitz 上的代码
我试图在带有 template-outlet 的 mat-select 中传递 #tmp,但无法显示选择选项。下面是我的代码和 stackblitz 的链接
<mat-form-field>
<mat-select
[ngModel]="selectedFoods"
(ngModelChane)="selectedFoods" placeholder="Favorite food" multiple>
<ng-container *ngFor="let food of allfoods"
[ngTemplateOutlet]="tmp"
[ngTemplateOutletContext]="{ $implicit: food}">
</ng-container>
</mat-select>
</mat-form-field>
<ng-template #tmp let-food>
<mat-option [value]="food.value">
{{food.viewValue}}
</mat-option>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
我有这个表单组:
this.form = fb.group({
'teacher': [''],
'schools': fb.array([
fb.group({
'school_name': [''],
'school_description': [''],
})
})
});
Run Code Online (Sandbox Code Playgroud)
问题是:
如何通过函数school_city以FormArray编程方式将新表单控件(命名)添加到特定*组?
我正在尝试使用 new Set 删除数组中的重复项给出错误“new Set(names).slice is not a function”
const names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];
const uniq = [ ...new Set(names) ];
console.log(uniq);
Run Code Online (Sandbox Code Playgroud)
这是stackblitz上的代码
使用 GET 方法的路由有效,但使用 POST 方法的路由无效。邮递员继续奔跑,没有回复。
这是我尝试过的,
import * as hapi from "@hapi/hapi";
const init = async () => {
const server: hapi.Server = new hapi.Server({
port: 3000,
host: 'localhost'
});
server.route({
method: 'POST', // if you change it to GET, it works
path: '/test',
handler: function (request, h) {
const payload = { username: 'testUserNames'};
return payload.username;
}
});
await server.start();
console.log('Server running on %s', server.info.uri);
}
process.on('unhandledRejection', (err) => {
console.log(err);
process.exit(1);
});
init();Run Code Online (Sandbox Code Playgroud)
可能是什么问题?我哪里错了?