javascriptcssangularjsjqlite

How to find the dynamic added classNames using angular


In my view I have couple of divs whose ids are :

<div ng-src="{{board[0].url)}}" autosize="off" id="{{board[0].name}}"></div>
  <div ng-src="{{{board[1].url)}}"autosize="off" id="{{board[1].name}}"></div>

I need to fetch those divs based on their ids and apply styling to it. How can I achieve that? Is there something like this :

angular.forEach($scope.boards, function(board){
    $document.find('#board.name').css({'width': board.position.width, 'height' : board.position.height})
}

Solution

  • you don't need to use jquery and ng-style directive could do the same thing for you

    <div ng-src="{{board[0].url)}}" ng-style="{width:board[0].position.width,height:board[0].position.height}" autosize="off" id="{{board[0].name}}"></div>
    <div ng-src="{{{board[1].url)}}" ng-style="{width:board[1].position.width,height:board[1].position.height}" autosize="off" id="{{board[1].name}}"></div>