I am new to Angular. Trying to build a sample appilication with VS.NET 2015 using angularjs.
When i try to load my application,I am facing this issue. Appreciate your help.
HTML
var app = angular.module('regApp', ['regApp2']);
app.controller('RegistrationCtrl', ['$scope', function ($scope, rescountries) {
$scope.GetCountries = function () {
var countries = rescountries.GetAllCountries();
countries.$promise.then(function (data) {
$scope.countries = data;
$scope.selectedCountry = 1;
}, function (error) { $scope.RegistrationResource = false });
};
}]);
Service.js
var app = angular.module('regApp2', []);
app.factory('RegistrationResource', ['$http', function ($http) {
var urlBase = 'http://localhost:62463/';
var rescountries = {};
rescountries.GetAllCountries = function () { return $http.get(urlBase + '/api/Registration/GetAllCountries') }
return rescountries;
}]);
Api call
using WebAPIAngular.DAL;
using WebAPIAngular.Entities;
using WebAPIAngular.Models;
using WebAPIAngular.Controllers;
namespace WebAPIAngular.WebAPI
{
[RoutePrefix("api/Registration")]
public class RegistrationController : ApiController
{
// GET api/GetAllStates/{id}
[Route("api/GetAllStates/{id}")]
public IEnumerable GetAllStates(int id)
{
return StateRepository.GetAllStates(id);
}
// GET api/GetAllCountries
[HttpGet]
[Route("api/GetAllCountries")]
public IEnumerable<Country> GetAllCountries()
{
return CountryRepository.GetAllCountries();
}
}
I am new to Angular. Trying to build a sample appilication with VS.NET 2015 using angularjs. When i try to load my application,I am facing this issue. Appreciate your help. HTML
In Body:
Controller.js
var app = angular.module('regApp', ['regApp2']); app.controller('RegistrationCtrl', ['$scope', function ($scope, rescountries) {
}]);
Service.js
var app = angular.module('regApp2', []); app.factory('RegistrationResource', ['$http', function ($http) {
var urlBase = 'http://localhost:62463/';
Api call
using WebAPIAngular.DAL; using WebAPIAngular.Entities; using WebAPIAngular.Models; using WebAPIAngular.Controllers; namespace WebAPIAngular.WebAPI { [RoutePrefix("api/Registration")] public class RegistrationController : ApiController { // GET api/GetAllStates/{id} [Route("api/GetAllStates/{id}")] public IEnumerable GetAllStates(int id)
{
return StateRepository.GetAllStates(id);
}
}