I am working on a div
with set dimensions, and I am populating it with content using ng-repeat
. My goal is to apply a CSS class to this div when it exceeds its limits. I attempted to use the length
property but without success.
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.placeholder = ['Koenigsegg CCXR Trevita',
'Lamborghini Veneno',
'W Motors Lykan Hypersport',
'Bugatti Veyron',
'Ferrari Pininfarina Sergio',
'Pagani Huayra BC',
'Ferrari F60 America',
'Bugatti Chiron',
'Koenigsegg One',
'Koenigsegg Regera'
];
});
div {
height: 40px;
width: 400px;
background: #f2f2f2;
padding: 5px;
}
span {
border: 1px solid #999;
padding: 3px;
display: inline-block;
margin: 2px;
border-radius: 3px;
}
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<div ng-app="myApp" ng-controller="personCtrl">
<span ng-repeat="j in placeholder;">
{{j}} ×
</span>
</div>
Note: I am limited to using only Javascript
or AngularJS
for this task.