Skip to content

Instantly share code, notes, and snippets.

@bunopus
Created May 25, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bunopus/18792002dd40eab33c83e0252aa955a5 to your computer and use it in GitHub Desktop.
Save bunopus/18792002dd40eab33c83e0252aa955a5 to your computer and use it in GitHub Desktop.
Angular 2 events (close) uses round braces notation
<div class="widget-list">
<someWidget
[ngClass]="{isBlue: true}"
*ngFor="let model of models"
*ngIf="isLoaded"
[model]="model"
(close)="onClose($event, model)"
></someWidget>
</div>
React - just regular function
class SomeWidget {
onClose(e, model) {
// onClose reaction
}
render() {
var widgets = models.map((model) => {
return isLoaded ? (
<someWidget
className="{{cn({isBlue: true})}}"
model="model"
close="onClose.bind(this, model)"
></someWidget>
) : null;
}):
return
(
<div class="widget-list">
{{widgets}}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment