I'm trying to extend Umbraco backend and need to send request to the custom controller form AngularJS.
What I've done is:
angular.module('AddAnswerModule', [])
.controller('AddAnswerController', AddAnswerController)
{
function AddAnswerController() {
}
AddAnswerController.prototype.greet = function ($scope, $http) {
alert(this.answer); //making suer it is working (yes, it is)
$a = $http.get("http://google.com"); //here the execution stops
alert($a);
};
}
I call alert especially for making sure contorller function is being called. Indeed it is working. But calling $http.get - stops all exectution.
I have tried different variants, but no luck. In the sample code I'm calling google just to be sure this page is accessable.
Can you, please, tell, what is wrong here and how can I cann $http.get inside Umbraco AngularJS controller?
Since google does not return any data like xml or json you're probably getting an error in your browsers console log. Perhaps have a read on the $http provider here too - https://docs.angularjs.org/api/ng/service/$http
Happy to hear you managed to get it all working - Care to share your solutions so others might benefit from your learnings too should they come across this post :)
AngularJS $http.get not working
Hi!
I'm trying to extend Umbraco backend and need to send request to the custom controller form AngularJS.
What I've done is:
I call alert especially for making sure contorller function is being called. Indeed it is working. But calling $http.get - stops all exectution. I have tried different variants, but no luck. In the sample code I'm calling google just to be sure this page is accessable.
Can you, please, tell, what is wrong here and how can I cann $http.get inside Umbraco AngularJS controller?
Thank you.
Hi Dronone
What is it that you're trying to build?
I think that it maybe a good idea to have a look at the Angularjs workbook for Umbraco to see how you can make custom controllers, services etc. in Umbraco https://github.com/umbraco/AngularWorkbook and perhaps you can find more useful information here https://our.umbraco.org/documentation/Extending/Property-Editors/
Since google does not return any data like xml or json you're probably getting an error in your browsers console log. Perhaps have a read on the $http provider here too - https://docs.angularjs.org/api/ng/service/$http
Hope this helps.
/Jan
Hi Jan!
Many thanks for your help. Having read that Angular samples for umbraco I made everything working at one :)
Hi Dron
Happy to hear you managed to get it all working - Care to share your solutions so others might benefit from your learnings too should they come across this post :)
/Jan
Well, that's really easy having read that books you have shared.
What is needed to know is that we need to use 'umbraco' module.
So may use this like:
angular.module("umbraco").controller("AddAnswerController", function ($http) { $a = $http.get("..."); //will work now });
is working on a reply...