For example:
<ul id= "scroller" data-ng-style="{'width': {{competitors.length * 114}} + 'px'}">
At first competitors array have two elements, the width is 228px;
then the array has six elements, the width shown in data-ng-style
is 668px
, but actually the width is still 228px
, why?
app.controller('intelligenceController', ['$scope', '$http', function($scope,$http) {
$scope.competitors = [
{
"competitorId": "excellent",
},
{
"competitorId": "average",
}
];
$scope.sumCompetitors = function(customList) {
if (0 === customList.length) {
$scope.competitors = $scope.competitors.concat({
"competitorId": "none",
});
} else {
$scope.competitors = $scope.competitors.concat(customList);
}
};
$http.get('./listCompetitors.json').success(function(competitorsList) {
if (false === competitorsList.hasError && 0 === competitorsList.content.code) {
$scope.sumCompetitors(competitorsList.content.data);
}
});
}]);