Do you have an input in your HTML with ng-model="eventDateFrom"?
When you change the value of the input by typing a new value in the
browser, does the watch get triggered?
Oh, I think I see the problem. You need to pass a function to $watch like
this:

$scope.$watch('eventDateFrom', function (value) {
  localData.add('eventDateFrom', value);
});

On Wed, Sep 24, 2014 at 3:02 PM, mark goldin <[email protected]> wrote:

> $scope.eventDateFrom = getFormattedDate(date);
> localData.add("eventDateFrom", $scope.eventDateFrom); // Will properly
> store key and value.
>
> $scope.$watch("eventDateFrom", localData.add("eventDateFrom",
> $scope.eventDateFrom)); // will not trigger localData.add
>
>
>
> On Wed, Sep 24, 2014 at 2:58 PM, Mark Volkmann <[email protected]>
> wrote:
>
>> Show me your call to $scope.$watch.
>>
>> On Wed, Sep 24, 2014 at 2:54 PM, mark goldin <[email protected]>
>> wrote:
>>
>>> That is exactly what I am doing, but "equivalent of setFavoriteNumber "
>>> is not getting called.
>>>
>>> On Wed, Sep 24, 2014 at 2:51 PM, Mark Volkmann <
>>> [email protected]> wrote:
>>>
>>>> No. Set up the watch in your controller where you have access to
>>>> $scope. Inject the service into that controller so you can call your
>>>> equivalent of setFavoriteNumber in the watch callback function.
>>>>
>>>> On Wed, Sep 24, 2014 at 11:50 AM, mark goldin <[email protected]>
>>>> wrote:
>>>>
>>>>> Where would I watch? Right in myDataSvc?
>>>>>
>>>>> On Wed, Sep 24, 2014 at 11:47 AM, Mark Volkmann <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> 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 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 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 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.

Reply via email to