<script>function MyCtrl($scope, myService) { $scope.service = myService;
}</script>
<div ng-controller="MyCtrl">
<input ng-model="service.value" />
</div>
If this doesn't help, please link to a plunkr that isn't working but you
think should be, and we might be able to fix it for you.
On Thu, Feb 6, 2014 at 1:37 PM, Yonatan Kra <[email protected]> wrote:
> Hi. Thanks. I'm an almost total newbie... could you explain please (or
> refer me to an example) how to use ng-model? I tried to use it in mt
> partial but it kept ignoring the service value.
> On Feb 6, 2014 7:22 PM, "Chris Rhoden" <[email protected]> wrote:
>
>> 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 a topic in the
>> Google Groups "AngularJS" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/angular/anQ2IGFnd4o/unsubscribe.
>> To unsubscribe from this group and all its topics, 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.
>>
> --
> 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.