I am porting an angular application to angulardart and I am encountering some challenges when it comes to the EventEmitter.
My current .ts file
looks like this:
import { Component, EventEmitter } from "@angular/core";
@Component({
selector: "app-post-create",
templateUrl: "./post-create.component.html",
styleUrls: ["./post-create.component.css"]
})
export class PostCreateComponent {
enteredTitle = "";
enteredContent = "";
postCreated = new EventEmitter();
onAddPost() {
const post = {
title: this.enteredTitle,
content: this.enteredContent
};
this.postCreated.emit(post);
}
}
According to an older post, EventEmitter is deprecated and shouldn't be used.
My current .dart file
looks like this:
import 'dart:async';
import 'package:angular/angular.dart';
import 'package:angular_components/angular_components.dart';
import 'package:angular_forms/angular_forms.dart';
@Component(
selector: 'app-post-create',
styleUrls: ['post_create_component.css'],
templateUrl: 'post_create_component.html',
directives: [
MaterialButtonComponent,
materialInputDirectives,
formDirectives
],
providers: [],
)
class PostCreateComponent {
String enteredTitle = '';
String enteredContent = '';
final _postCreatedController = new StreamController<String>();
@Output
Stream<String> get postCreated => _postCreatedController.stream;
onAddPost() {
Map<String, String> post = {
'title': this.enteredContent,
'content': this.enteredContent
};
}
}
My dart file needs to be fixed. I am not using the Stream correctly. Any help is appreciated.