Reputation: 10791
I want to add a class to the .container
element when the content loads of an angularjs app:
Part of my code is as follows, how can I do this, not sure how it's done?
HTML
<div class="container " ng-view>
..
JS
**app.controller('ShowImages', function($scope, InstagramAPI){
$scope.layout = 'grid';
$scope.data = {};
$scope.pics = [];
InstagramAPI.fetchPhotos(function(data){
$scope.pics = data;
console.log("length is "+data.length)
});
});**
Upvotes: 0
Views: 688
Reputation: 2330
just do this :
<div class="container" ng-class="{'customclass' : pics.length > 0}"></div>
Upvotes: 0
Reputation: 3062
I would suggest
<div class="container" data-ng-class="{ 'yourcustomclass': pics.length > 0 }"></div>
Upvotes: 1