https://github.com/paveldymkov/ng-to-parent
https://github.com/paveldymkov/ng-to-parent
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/paveldymkov/ng-to-parent
- Owner: PavelDymkov
- License: mit
- Created: 2022-05-17T15:42:41.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-17T16:06:10.000Z (about 3 years ago)
- Last Synced: 2025-03-19T13:11:20.394Z (4 months ago)
- Language: TypeScript
- Size: 213 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ng-to-parent

Send data to parent.
```ts
import { Message } from "ng-to-parent";// create a message type
export const inputData = new Message();
``````ts
import { ToParent } from "ng-to-parent";@Component({
selector: "app-child",
template: `
Click me!
`,
// It's important to provide
// in the component, not to a module
providers: [ToParent], // << !!!
})
export class ChildComponent {
constructor(private toParent: ToParent) {}send(text: string): void {
this.toParent.send(inputData, void 0);
}
}
``````ts
import { FromChild } from "ng-to-parent";@Component({
selector: "app-parent",
template: "",
// It's important to provide
// in the component, not to a module
providers: [FromChild], // << !!!
})
export class ParentComponent {
constructor(fromChild: FromChild) {
fromChild.listen(inputData).subscribe((text) => {
console.log(text);
});
}
}
```