show user in show

restrict show actions
This commit is contained in:
2020-05-03 17:18:23 +02:00
committed by smuddy
parent 8619027fdb
commit 8b6ff52054
13 changed files with 114 additions and 34 deletions

View File

@@ -0,0 +1 @@
{{name$|async}}

View File

@@ -0,0 +1,25 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {UserNameComponent} from './user-name.component';
describe('UserNameComponent', () => {
let component: UserNameComponent;
let fixture: ComponentFixture<UserNameComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [UserNameComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserNameComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,23 @@
import {Component, Input} from '@angular/core';
import {UserService} from '../user.service';
import {map} from 'rxjs/operators';
import {Observable} from 'rxjs';
@Component({
selector: 'app-user-name',
templateUrl: './user-name.component.html',
styleUrls: ['./user-name.component.less']
})
export class UserNameComponent {
public name$: Observable<string>;
constructor(
private userService: UserService
) {
}
@Input() set userId(id: string) {
this.name$ = this.userService.getUserbyId$(id).pipe(map(_ => _.name));
}
}

View File

@@ -0,0 +1,11 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {UserNameComponent} from './user-name.component';
@NgModule({
declarations: [UserNameComponent],
exports: [UserNameComponent],
imports: [CommonModule]
})
export class UserNameModule {
}