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

940 ملاحظات
پہلے نہ پڑھے ہوئے پیغام پر جائیں

Freewind

نہ پڑھا ہوا،
25 مارچ، 2012، 10:54:53 AM25/3/12
بنام ang...@googlegroups.com
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?

Peter Bacon Darwin

نہ پڑھا ہوا،
25 مارچ، 2012، 10:55:46 AM25/3/12
بنام ang...@googlegroups.com
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.

Freewind

نہ پڑھا ہوا،
25 مارچ، 2012، 11:14:18 AM25/3/12
بنام ang...@googlegroups.com
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>
To unsubscribe from this group, send email to angular+unsubscribe@​googlegroups.com.

Peter Bacon Darwin

نہ پڑھا ہوا،
25 مارچ، 2012، 12:48:04 PM25/3/12
بنام ang...@googlegroups.com
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.

Vojta Jína

نہ پڑھا ہوا،
26 مارچ، 2012، 12:31:04 AM26/3/12
بنام ang...@googlegroups.com
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.

>>> angular+u...@googlegroups.com.


>>> For more options, visit this group at
>>> http://groups.google.com/group/angular?hl=en.
>>
>>

> --
> 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/-/gmZdiUNOY70J.


>
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to

> angular+u...@googlegroups.com.

Freewind

نہ پڑھا ہوا،
26 مارچ، 2012، 6:53:40 AM26/3/12
بنام ang...@googlegroups.com
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

>>> angular+unsubscribe@​googlegroups.com.


>>> For more options, visit this group at
>>> http://groups.google.com/​group/angular?hl=en.
>>
>>
> --
> 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/-/gmZdiUNOY70J.
>
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to

> angular+unsubscribe@​googlegroups.com.

سبھی کو جواب دیں
مصنف کو جواب دیں
فارورڈ کریں
0 نئے پیغامات