Skip to content

Instantly share code, notes, and snippets.

@armanozak
Last active May 9, 2019 08:30
Show Gist options
  • Save armanozak/abfc6d8f5914872d421a63a2208c85a9 to your computer and use it in GitHub Desktop.
Save armanozak/abfc6d8f5914872d421a63a2208c85a9 to your computer and use it in GitHub Desktop.
Angular Context - One-way Data-binding (#1) #blog
@Component({
selector: 'my-app',
template: `
<context-provider
provide="progress progressStriped progressType"
[contextMap]="{progressType: 'type'}"
>
<one-way></one-way>
</context-provider>
`,
})
export class AppComponent {
progress = 70;
progressStriped = true;
progressType = 'info';
}
@Component({
selector: 'one-way',
template: `
<progressbar
contextConsumer
[contextMap]="{progress: 'value', progressStriped: 'striped'}"
></progressbar>
`,
})
export class OneWayComponent {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment