0

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)
    });
  });**

2 Answers 2

1

I would suggest

<div class="container" data-ng-class="{ 'yourcustomclass': pics.length > 0 }"></div>
Sign up to request clarification or add additional context in comments.

Comments

0

just do this :

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

1 Comment

I get a console error when adding that: machinas.com/wip/machinas/instagramfeed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.