我想从外部json文件配置我的Angular 2 App。
在我的main.ts中加载config.json
getHttp().get('/config.json')
.map(response => response.json();)
.subscribe(
data => {
let clientConf: ClientConfig = data;
// here I want to pass clientConf to AppModule
platformBrowserDynamic().bootstrapModule(AppModule);
});
Run Code Online (Sandbox Code Playgroud)
我想知道如何将clientConf传递给AppModule以在app.module.ts中使用:
@NgModule({
...
providers: [
{ provide: Configuration, useValue: clientConf }
...
Run Code Online (Sandbox Code Playgroud) 在我的Spring Boot应用程序中,我有这样的实体:
@Entity
@Table(name = "UserENT")
public class User implements Serializable {
@Id
private String id;
private Data data;
...
Run Code Online (Sandbox Code Playgroud)
我想实现该对象数据将以json格式存储在DB中.但是从DB中选择时,它将映射到Data对象上.
谢谢你的建议.
我有一个使用Angular CLI生成的Angular 2项目(通过键入ng new myProject
).
如何配置构建位置,因此在构建之后,我将拥有一个包含所有HTML,JS和其他资源的单独文件夹?
我的图像在中间有一个文件,周围有一些(地毯,桌子的桌子等)
我想删除所有周围,只有一个文件. 我尝试了阈值和adaptiveThreshold,但我没有取得多大成就.
因此,我想采取周围的样本,并基于删除所有周围.
这在OpenCV中是否可行?
嗨我在Angular 2应用程序中有以下问题.
我有BroadcastService:
@Injectable()
export class BroadcastService {
private broadcastSubject: BehaviorSubject<Event> = new BehaviorSubject<Event>(0);
public next(event: Event): void {
return this.broadcastSubject.next(event);
}
public subject(event: Event): Observable<Event> {
return this.broadcastSubject.asObservable().filter(e => e === event);
}
}
Run Code Online (Sandbox Code Playgroud)
我在这样的组件中使用它:
export class MyComponent implements OnInit {
constructor(public broadcastService: BroadcastService) {
this.broadcastService.subject(Event.BLA_EVENT).subscribe(() => this.bla());
}
...
Run Code Online (Sandbox Code Playgroud)
每当我路由到'/ mycomponent'时,都会调用MyComponent.constructor,因此会多次订阅Event.BLA_EVENT.
有什么建议如何防止多次订阅?