Cre*_*Dip 4 api node.js express angularjs
我有这些api调用,我想在我的角度控制器中调用它们?任何例子都会有所帮助.
app.post('/user/auth', users.auth);
app.get('/user/logout', helpers.isAuthenticated, users.logout);
Run Code Online (Sandbox Code Playgroud)
你只需要使用这样的$http服务:
angular.module('app', [])
.controller('ctrlname', ['$http', function($http){
//POST sample
$http.post('/user/auth', users.auth).then(function(response){
//handle your response here
});
//GET sample
//substitute 'param1' and 'param2' for the proper name the API is expecting these parameters
$http.get('/user/logout/?param1=' + helpers.isAuthenticated + '¶m2=' + users.logout).then(function(response){
//handle your response here
});
}]
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12919 次 |
| 最近记录: |