小编rus*_*sna的帖子

从动态创建的子组件向父组件发出事件

我有一个滑块,其中是动态创建的项目 - 这些是子组件。

滑块的 ng-container 父模板:

<div id="slider-wrapper">
    <ng-container appSliderForm *ngFor="let question of questionsInSlider"
                          [questionTest]="question" (onRemove)="removeQuestion($event)">
    </ng-container>
</div>
Run Code Online (Sandbox Code Playgroud)

这些子组件由 appSliderForm 指令创建:

@Directive({
  selector: '[appSliderForm]'
})
export class FormSliderDirective implements OnInit {

  @Input()
  questionTest: QuestionInSlider;

  constructor(private resolver: ComponentFactoryResolver, private container: ViewContainerRef) {}

  ngOnInit(): void {
    const factory = this.resolver.resolveComponentFactory<TestQuestionInSliderComponent>(TestQuestionInSliderComponent);
    const component = this.container.createComponent(factory);
    component.instance.questionTest = this.questionTest;
    component.instance.ref = component;
  }

}
Run Code Online (Sandbox Code Playgroud)

在我的子组件中,我有一个删除功能,用于将自身从滑块中删除。

@Component({
  selector: 'app-test-question-in-slider',
  templateUrl: './test-question-in-slider.component.html',
  styleUrls: ['./test-question-in-slider.component.less']
})
export class TestQuestionInSliderComponent {

  questionTest: QuestionInSlider;

  ref: any;

  @Output() …
Run Code Online (Sandbox Code Playgroud)

angular-directive angular angular5 angular-event-emitter angular-dynamic-components

6
推荐指数
1
解决办法
2506
查看次数

Flux 中 Mono 的 doOnSuccess 方法相当于什么?

在我之前版本的 API 中,我使用Mono作为返回类型。当一切正常时,我登录了doOnSuccess方法。

API 方法返回类型更改为Flux后,我无法使用doOnSuccess进行日志记录。

请问 Flux 的doOnSuccess方法相当于什么?

java spring project-reactor spring-webflux

5
推荐指数
1
解决办法
6454
查看次数

如何在Kotlin中重载构造函数的不同之处在于Lambda返回类型

我有两个构造函数,它们的lambda返回类型不同。有什么选择可以使它们超载吗?我试图使用JvmOverloads注释,但是没有用。

constructor(db : Database, handler: ( transaction: Transaction) -> Unit) : this(db, Handler<Transaction>( {handler.invoke(it)}))

@JvmOverloads
constructor(db : Database, handler: ( transaction: Transaction) -> Any) : this(db, Handler<Transaction>( {handler.invoke(it)}))
Run Code Online (Sandbox Code Playgroud)

lambda constructor-overloading kotlin

3
推荐指数
1
解决办法
766
查看次数