You could bind to the service from your directive.
mod.directive('myDirective', ['myService', function (myService) {
return {
restrict: 'A',
...
};
});
This is usually not necessary, though, and probably means that the
directive is doing too much if it's absolutely necessary.
ng-model could, for instance, depend on a Models service to pull its
object, but it uses attributes instead. Generally, that's the right way to
go.
On Thu, Feb 6, 2014 at 12:11 PM, Yonatan Kra <[email protected]> wrote:
> Hi,
> I have a service that keeps my data across views (a simple json).
> Is there a way for me to watch on changes for this service from a
> directive?
>
> --
> 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.
>
--
chrisrhoden
--
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.