show user in show
restrict show actions
This commit is contained in:
1
src/app/services/user/user-name/user-name.component.html
Normal file
1
src/app/services/user/user-name/user-name.component.html
Normal file
@@ -0,0 +1 @@
|
||||
{{name$|async}}
|
||||
25
src/app/services/user/user-name/user-name.component.spec.ts
Normal file
25
src/app/services/user/user-name/user-name.component.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
23
src/app/services/user/user-name/user-name.component.ts
Normal file
23
src/app/services/user/user-name/user-name.component.ts
Normal 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));
|
||||
}
|
||||
|
||||
}
|
||||
11
src/app/services/user/user-name/user-name.module.ts
Normal file
11
src/app/services/user/user-name/user-name.module.ts
Normal 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 {
|
||||
}
|
||||
Reference in New Issue
Block a user