I create directives that use a publish/subscribe pattern.  They subscribe 
to a data channel, and when data is there, they populate a view model.  In 
this way they are not concerned with how the data get's there, just what to 
do when it is.  Here is a sample of the link function:

_link = function(scope, element, attributes) {
    var _modelChannel = attributes['subscribe'];

    angular.extend(scope, { viewModel: {}, modelChannel: _modelChannel });

    // listen for changes to the view model and add to scope on change
    _pubsub.subscribe(_modelChannel,
        function(data) {
            angular.extend(scope, { viewModel: data });
        });
}

-- 
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/groups/opt_out.

Reply via email to