Skip to content

Instantly share code, notes, and snippets.

@alexalannunes
Last active July 16, 2019 22:50
Show Gist options
  • Save alexalannunes/6b5b2cd32f3b63c2db53fd37a3c3f402 to your computer and use it in GitHub Desktop.
Save alexalannunes/6b5b2cd32f3b63c2db53fd37a3c3f402 to your computer and use it in GitHub Desktop.
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>
@maxmillernunes
Copy link

Show de bola.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment