Created
June 2, 2016 07:14
-
-
Save zuzkins/25f0dd8d1d31af6d8a057f92cd6101d2 to your computer and use it in GitHub Desktop.
TIL you can put @input() decorator on setter and transform the value. It does not have to be put on property.
This file contains 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
@Component( selector: 'user-role', | |
template: r''' | |
<span *ngIf="userRole != null && long" >{{ userRole.completeLabel }}</span> | |
<span *ngIf="userRole != null && !long" >{{ userRole.label}}</span> | |
''') | |
class UserRoleComponent { | |
UserRole userRole; | |
@Input() | |
bool long = false; | |
@Input() | |
set role(var role) { | |
if (role is UserRole) this.userRole = role as UserRole; | |
final UserRole found = findRoleDescriptor(role); | |
this.userRole = found; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
no 4th line there is space missing :-D