我只是学习Pluralsight - 使用RxJS开始反应式编程
为什么不工作?
我使用RXJS 6.2.0
import {Observable} from 'rxjs';
const numbers = [1, 5, 10];
const source = Observable.create(observer => {
let index = 0;
let produceValue = () => {
observer.next(numbers[index++]);
if (index < numbers.length) {
setTimeout(produceValue, 2000);
} else {
observer.complete();
}
};
produceValue();
}).map(n => n * 2)
.filter(n => n > 4);
source.subscribe(
value => console.log(`value: ${value}`),
e => console.log(`error: ${e}`),
() => console.log('complete')
);
Run Code Online (Sandbox Code Playgroud) 我刚刚学习了 Udemy - 完整的 Angular 课程 - 从初学者到高级在将产品保存在 Firebase“类别”:“未定义”中有一个小问题
我使用角版本
角 CLI:6.0.8
"products" : {
"-LGoVcK9sUP-lzEqXy-1" : {
"category" : "undefined",
"imageUrl" : "imageUrl",
"price" : 12,
"title" : "title"
}
Run Code Online (Sandbox Code Playgroud)
<form #f="ngForm" (ngSubmit)="save(f.value)">
<div class="form-group">
<label for="title">Title</label>
<input ngModel name="title" type="text" id="title" class="form-control">
</div>
<label for="price">Price</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">$</span>
</div>
<input ngModel name="price" type="number" class="form-control" id="price">
</div>
<div class="form-group">
<label for="category">Category</label>
<select [ngModel] name="category" id="category" class="form-control">
<option value=""></option>
<option *ngFor="let c of categories$ | async" …Run Code Online (Sandbox Code Playgroud)