You could watch the scope property for changes and then pass the new value
to the setFavoriteNumber method of the service. Something like this:
$scope.$watch('myScopeProp', myDataSvc.setFavoriteNumber);
On Wed, Sep 24, 2014 at 11:43 AM, mark goldin <[email protected]> wrote:
> And that is what I kind of have. But my problem is that UI is bound to
> $scope. When I select a new vlaue that value is not getting into
> myDataSvc.
>
> On Wed, Sep 24, 2014 at 11:41 AM, Mark Volkmann <[email protected]
> > wrote:
>
>> One way to do that is to put the data in a service and inject that
>> service everywhere you need it. For example,
>>
>> myModule.factory('myDataSvc', function () {
>> var svc = {};
>> var favoriteNumber;
>>
>> svc.setFavoriteNumber = function (n) { favoriteNumber = n; };
>> svc.getFavoriteNumber = function () { return favoriteNumber; };
>>
>> return svc;
>> }
>>
>> On Wed, Sep 24, 2014 at 11:35 AM, mark goldin <[email protected]>
>> wrote:
>>
>>> I have UI that is bound to some $scope values. When I go deeper into my
>>> application I need to use values entered in UI. At some point data that was
>>> put on $scope by UI is not available. How can I share data collected from
>>> UI across the app?
>>>
>>> Thanks
>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>> --
>> 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/dkXHM4dufvw/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/d/optout.
>>
>
> --
> 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.
>
--
R. Mark Volkmann
Object Computing, Inc.
--
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.