I use ng-repeat to present a list of songs. I use ng-class to determine 
which songs should have a "song-unavailable" class. I also have a draggable 
directive for jQuery UI.

<li ng-repeat="song in songs" ng-class="{'song-unavailable' : song.owned 
=== true}"  draggable>

myApp.directive('draggable', function() {
        return {
            restrict:'A',
            link: function(scope, element, attrs) {
                    element.draggable({
                        revert: false,
                        helper: 'clone',
                        appendTo: '#my_table',
                        zIndex:1000,
                        cursorAt: { left: 50 },
                        start: function(event, ui) {
                            $('body').css('cursor', 'move');
                        },
                    });
            }
        };
});

Here's the problem: I only want songs to be draggable if song.owned === 
true. However, the directive is initialized before the ng-class expression 
is evaluated. So, all songs have the directive and are draggable. What can 
I do to prevent songs that aren't owned to not be draggable?

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to