Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider")

Showing 1-6 of 6 messages
Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider") Freewind 3/25/12 7:54 AM
Hello, everyone. I'm new to angularjs, and write a simple test, but get such error:

    Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider")

The error is shown in firebug console when the page is loading.

And my code is:

<script lang="javascript">
function TodoFormCtrl($scope, $xhr) {
$scope.todos = [@myMessages.map("'" + _.content + "'").mkString(",")];
$scope.newTodo = "";
$scope.submit = function() {
var todo = this.newTodo;
if(todo) {
$scope.todos.push(todo);
$xhr("POST", "@routes.Messages.create", {xxx:todo}, function(res){
alert("S:" + res);
},
function(res){
alert("F:" +res);
})
}
}
}
</script>

What's wrong with the `$xhr` in my code?
Re: [angular.js] Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider") Pete Bacon Darwin 3/25/12 7:55 AM
The $xhr service is known as $http in v1.0

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/bPDdsR1-z3YJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Re: [angular.js] Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider") Freewind 3/25/12 8:14 AM
Thank you, I changed it to `$http`, but this time, when I click the `add` button, it shows the following error:

[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: http://localhost:9000/assets/javascripts/angular-1.0.0rc1.min.js :: <TOP_LEVEL> :: line 105"  data: no]
Line 71

And my code is:

<script lang="javascript">
function TodoFormCtrl($scope, $http) {
	$scope.todos = [];
	$scope.newTodo = "";
	$scope.submit = function() {
		var todo = $scope.newTodo;
		if(todo) {
			$scope.todos.push(todo);
			$http("POST", "/messages/_create", "", function(res){
				alert("S:" + res);
			}, function(res){
				alert("F:" +res);
			});
		}
	}
}
</script>
Re: [angular.js] Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider") Pete Bacon Darwin 3/25/12 9:48 AM
I don't think you are using the correct syntax.  Take a look at the v10.6 documentation for $http: http://docs-next.angularjs.org/api/angular.module.ng.$http.  Also if you can put together a jsfiddle that demonstrates the error then you will get more concrete solutions to your problem.
Pete

To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/gmZdiUNOY70J.

To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Re: [angular.js] Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider") Vojta Jína 3/25/12 9:31 PM
Hey freewind,

welcome to Angular world. We use jsfiddle, so please create simplest
possible fiddle, that shows your problem.

You can start from this one, which includes the latest Angular:
http://jsfiddle.net/vojtajina/una6x/

V.

> https://groups.google.com/d/msg/angular/-/gmZdiUNOY70J.


>
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to
> angular+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/angular?hl=en.

Re: [angular.js] Error: Unknown provider: $xhrProvider <- $xhr ("$xhrProvider") Freewind 3/26/12 3:53 AM
Thanks for the good suggestion about jsfiddle. I never realize there is such a good tool for asking questions, I will use it next time