Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paveldymkov/ng-to-parent
https://github.com/paveldymkov/ng-to-parent
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/paveldymkov/ng-to-parent
- Owner: PavelDymkov
- License: mit
- Created: 2022-05-17T15:42:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-17T16:06:10.000Z (over 2 years ago)
- Last Synced: 2024-11-11T01:29:00.087Z (2 months ago)
- Language: TypeScript
- Size: 213 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ng-to-parent
![tests: passing](https://raw.githubusercontent.com/PavelDymkov/ng-to-parent/master/badges/tests.svg)
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);
});
}
}
```