Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getCatalogs(): Observable<Catalog[]> {
- const api_path = this.dataUrl + `metadata/getcatalogs/name/?user=${this.user.username}&password=${this.user.password}`;
- return this.http.get<Catalog[]>(api_path);
- }
- onSelect(user: User): void {
- this.selectedUser = user;
- this.datasourceService.user = user; // sets the user, as i can't figure out how to send it as a parameter, and subscribe to that call
- this.datasourceService.getCatalogs() // had to run this here so that the Observable would have at least one subscription to make it run.
- .subscribe(catalogs => {this.catalogs = catalogs; });
- }
- @Input() user: User;
- public catalogs$: Observable<Catalog[]>;
- constructor(private datasourceService: DatasourceService) { }
- ngOnInit() {
- this.catalogs$ = this.datasourceService.getCatalogs();
- this.datasourceService.getCatalogs()
- .subscribe(catalogs => {this.catalogs = catalogs; });
- }
- <div *ngIf="user">
- <h3>Catalogs for User: {{user.username}}</h3>
- <ul >
- <li *ngFor="let catalog of catalogs$ | async">
- {{ catalog.name }}
- </li>
- </ul>
- </div>
- providers: [DatasourceService],
Add Comment
Please, Sign In to add comment