














这些天,有在asp.net web Site㠌入angularjs。
在表单设计时,一些静态数据往往需要从数据库读取。
简化代码,Insus.NET把其重构成一个Service。数据服务或angularjs工厂直接调用即可。

'use strict'; eamApp.service('fetchService', ['$http', function ($http) { this.fetchData = function (url, args) { return $http({ method: 'POST', url: url, dataType: 'json', headers: { 'Content-Type': 'application/json; charset=utf-8' }, data: JSON.stringify(args) }).then(function (response) { return response.data; // 返回响应数据 }); }; }]);
fetchService.js
想了解有关service & factory区别,可以搜索。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。