Last active
July 16, 2019 22:50
-
-
Save alexalannunes/6b5b2cd32f3b63c2db53fd37a3c3f402 to your computer and use it in GitHub Desktop.
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
app.directive("corMediaSigaBadge", function() { | |
return { | |
restrict: "A", | |
template: `<span class="badge {{class}}">{{value}}{{showPercent ? '%' : ''}}</span>`, | |
scope: { | |
value: "=", | |
showPercent: "=" // boolean | |
}, | |
link: function($scope, $elem, $attr) { | |
$scope.class = ""; | |
if ($scope.value > 80 && $scope.value <= 100) { | |
$scope.class = "badge-success"; | |
} else if ($scope.value > 60 && $scope.value <= 80) { | |
$scope.class = "badge-info"; | |
} else if ($scope.value > 30 && $scope.value <= 60) { | |
$scope.class = "badge-warning"; | |
} else { | |
$scope.class = "badge-primary"; | |
} | |
} | |
}; | |
}); | |
// <span cor-media-siga-badge show-percent="true" value="43"></span> | |
// <span cor-media-siga-badge show-percent="true" value="user.media"></span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Show de bola.