我有一个Angular应用程序,我正在尝试将预订列表从服务器下载到Angular服务。我希望让所有组件都能够将保留数组作为可观察对象来获取,并能够过滤和限制结果。现在我使用的是BehaviorSubject。这是我的代码。
//reservation.service.ts (partial code)
@Injectable()
export class TripService {
public Trips: Object[] = [];
public TripSubject: Subject<Object[]> = new BehaviorSubject<Obje
我有一个缓存服务,我想在其中存储数据。
angular.module('core').service('markerCache', function(){
var cache = [];
this.set_cache = function(arr){
cache = arr;
this.cached = true;
};
this.cached = false; //this must be read-only and must be property, not function
});
如果可能的
在角4+中有一个反应性形式,其中有多个check boxes,如下所示:
现在,用户可以选择尽可能多的复选框。因此,此表单的输出是选中的复选框的数组,如下所示:
[
"I have a bike",
"I have a nothing",
"I have a test"
]
我不知道如何在reactive forms中处理这个问题。请注意,我使用的是以下内容:
import {FormGroup, FormBuilder, Validators} from "@angular/forms";
我想要的:
在将