在内容加载angularjs时将类添加到元素

时间:2015-07-10 12:38:49

标签: angularjs

我想在内容加载angularjs app时向.container元素添加一个类:

我的部分代码如下,我该怎么做,不确定它是如何完成的?

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 个答案:

答案 0 :(得分:1)

我建议

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

答案 1 :(得分:0)

这样做:

class AB {
    public void dog() {
        System.out.println("Dog");
    }
}

class C extends AB {    
    public void cat() {
        System.out.println("Cat");
    }
}

class ABC {
    public static void main(String[] args) {
        AB obj1 = new AB();
        C obj2 = new C();
        AB obj3 = new C();
        obj1.dog();
        obj2.cat();
        obj2.dog();
        obj3.dog();
        //obj3.cat();
    }
}