I have a problem to get response from my API-controller from my factory.
I get error 404 page not found.
I got the right .js-file
in the HTML-document
and the routing seems fine.
App.js:
module.factory('userFactory', function($http) {
return {
getFormData: function(callback) {
$http.get('/api/GetMessage').success(callback);
}
}
});
module.controller("messageController", function($scope, userFactory) {
$scope.getMessage = function() {
userFactory.getFormData(function(results) {
$scope.text = results;
});
}
});
API-controller:
using System.Web.Http;
namespace kittyChatt.Backend.Controllers {
public class GetMessageController : ApiController
{
public object Get()
{
object obj = "hello world";
return obj;
}
}
}
I want the hello world to show whene i hit a button in my view.
View:
<div>
<button ng-click="getMessage()">Get my message</button>
<p>{{text}}</p>
</div>
Plz help!