Why do you need your first variable? I couldn't understand.

Well, about your error, if $scope.todos is a collection, you should use 
$watchCollection instead of $watch and be aware that angular just watches 
its own elements.

let us know if this worked for you.

Em sexta-feira, 16 de maio de 2014 02h40min58s UTC-3, [email protected] 
escreveu:
>
> I am creating an simple TODO app using AngularJS, i POST the data to 
> server when response comes, that response i want to store it existing 
> variable and refresh the view. i.e
>
> // This stores on page load, its working fine
> var todos = $scope.todos = sever_passed_data;
>
> but when i do,
>
> $scope.$watch('todos', function () {
>     var request = $http({
>         method: "post",
>         headers: {'Content-Type': 'application/x-www-form-urlencoded'},
>         url: my_url,
>         data: $.param({todos_list: angular.toJson(todos)})
>     });
>     request.success(function(responce){
>         var todos = $scope.todos = responce;
>     });}, true);
>
> after this it gives me weird(*it goes in infinite loop and posting data 
> to server*) output, i mean the responce doesn't stores in todos variable.
>

-- 
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