user1937021
user1937021

Reputation: 10791

add class to element when content loads angularjs

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

Answers (2)

Arno_Geismar
Arno_Geismar

Reputation: 2330

just do this :

<div class="container" ng-class="{'customclass' : pics.length > 0}"></div>

Upvotes: 0

Starscream1984
Starscream1984

Reputation: 3062

I would suggest

<div class="container" data-ng-class="{ 'yourcustomclass': pics.length > 0 }"></div>

Upvotes: 1

Related Questions