Angular - ng-repeat orderBy and ng-class w. function
AngularJS
ng-repeat using orderBy
ng-class, function defining if team is my team and add class if true.
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<div class="inline">
<div class="span-width">State:</div>
<span >aaaaa</span>
</div>
CSS
.span-width{
width:60px
}
.inline{
display: inline-flex;
}
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl', ['$scope', function($scope) {
var vm = $scope;
vm.myTeamId = 2;
vm.isThisMyTeam = function(team) {
console.log(team);
if( vm.myTeamId === team.teamId ) {
return true;
}
}
vm.teamsAndPoints = [
{
"teamId": 1,
"teamName": "One",
"teamScore": 54
},
{
"teamId": 2,
"teamName": "Two",
"teamScore": 87
},
{
"teamId": 3,
"teamName": "Three",
"teamScore": 119
},
{
"teamId": 4,
"teamName": "Four",
"teamScore": 45
},
{
"teamId": 5,
"teamName": "Five",
"teamScore": 64
}
];
}]);