javascript - Automatic "proxy" creation for ASP.NET MVC Controller for AngularJs service -


when i'm using asp.net mvc controller angularjs, controller contains json result functions. , when create angularjs service allways same code write service or post calls asp.net controller functions.

mvc home controller functions:

[angularcreateproxy] public jsonresult initunittestpersonentry() {     return json(new personentry(), jsonrequestbehavior.allowget); }  [angularcreateproxy] public jsonresult initunittestsearchmodel() {     personsearchmodel searchmodel = new personsearchmodel() {name = string.empty};     return json(searchmodel, jsonrequestbehavior.allowget); }  [angularcreateproxy] public jsonresult addunittestperson(personentry entry) {     personentries.add(entry);     return json(entry, jsonrequestbehavior.allowget); } 

my automaticly created angularjs home service:

function homepsrv($http, $log) {      this.log = $log, this.http = $http;  }  homepsrv.prototype.initunittestpersonentry = function () {    return this.http.get('/home/initunittestpersonentry').then(function (result) {       return result.data;    }); }  homepsrv.prototype.initunittestsearchmodel = function () {     return this.http.get('/home/initunittestsearchmodel').then(function (result) {         return result.data;     }); }  homepsrv.prototype.addunittestperson = function (entry) {     return this.http.post('/home/addunittestperson',entry).then(function (result) {       return result.data;     }); }  angular.module("app.homepsrv", [])    .service("homepsrv", ['$http', '$log', homepsrv]); 

i've written own little "proxy" (don't know if right naming) automaticly creates angularjs service controller json result functions new javascript file - works fine far.

my question are:

whats right way handle task there github projekt out there supports allready or how solving "problem"?

whats right naming because can't find solution , don't know if "proxy" right?

i've created own github repo using t4 template create proxy functions

https://github.com/squadwuschel/mvccontrollertoproxygenerator


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -