I need to call my webAPI actions from AngularJS. I can do simple CRUD but if I want to call specific action, how should I call it?
For example I can call POST by Calling save from AngularJS Resource.
Here is the TypeScript code I'm using:
Link to the source of the code
/// <reference path="../models/ILogin.ts" />
module App.Resources {
"use strict";
export interface ILoginResourceDef
extends ng.resource.IResource<Models.ILogin> {
}
}
/// <reference path="ILoginResourceDef.ts" />
module App.Resources {
"use strict";
export interface ILoginResource
extends ng.resource.IResourceClass<Resources.ILoginResourceDef> {
}
}
/// <reference path="../models/ILogin.ts" />
/// <reference path="../models/Login.ts" />
/// <reference path="../resources/ILoginResource.ts" />
/// <reference path="../scope/ILoginScope.ts" />
module App.Controllers {
"use strict";
export class AccountController {
constructor(private $scope: Scope.ILoginScope, private loginResource: Resources.ILoginResource) {
$scope.newLogin = new Models.Login();
}
public login(): void {
this.loginResource.save(this.$scope.newLogin, // This save trigger the POST
() => this.logme(),
() => { alert('failure'); });
}