[英]JS framework for client-side to communicate with rest-api
I'm looking for a lightweight js framework to implement client-side web-app that would communicate with server through rest api. 我正在寻找一个轻量级的js框架来实现可通过rest api与服务器通信的客户端Web应用程序。
I thought about react.js - but my colleagues refused to use it due to lack of any templating. 我考虑过react.js-但由于缺少模板,我的同事拒绝使用它。 Angular.js is too big - my project will use only a couple of pages and lazy-load content + send some stuff over rest api. Angular.js太大-我的项目将仅使用几个页面并延迟加载内容+通过rest api发送一些内容。
Any ideas? 有任何想法吗? What would you prefer? 您想要什么?
Thank you for any help 感谢您的任何帮助
AngularJS + Restangular for RESTful interaction is a breeze. 用于RESTful交互的AngularJS + Restangular轻而易举。
app.config(['RestangularProvider',function(RestangularProvider) {
RestangularProvider.setBaseUrl('https://api.yoursite.com/');
}]);
angular.module('my.controllers')
.controller('MyController', ['$scope', 'Restangular', function($scope, Restangular) {
var user = Restangular.one('user', user_id);
var info = user.one('info');
info.get().then(function(res) {
$scope.userInfo = res.data;
});
}]);
userInfo
in your view 在您的视图中访问userInfo
<div ng-controller="MyController">
<pre> {{userInfo | json}}</pre>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.