Created
May 25, 2016 15:00
-
-
Save bunopus/18792002dd40eab33c83e0252aa955a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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