如何在anguarjs中连接REST API [英] How to connect REST API in anguarjs

查看:132
本文介绍了如何在anguarjs中连接REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用mongodb和nodejs并创建REST API(例如http:// localhost:3000 / Records)但现在我想将此API连接到angularjs应用程序。



我尝试过:



CREATED rest API方法如HTTP:// LOCALHOST:3000 / DETAILS。

I used mongodb and nodejs and create REST API(for example "http://localhost:3000/Records") but now i want to connect this API to angularjs application.

What I have tried:

CREATED rest API METHODS LIKE HTTP://LOCALHOST:3000/DETAILS.

推荐答案

要从角度访问其余的API,在控制器内部,无论你的应用程序的任何部分正在访问它,你都需要使用
To access a rest API from angular, inside your controller for whatever portion of your app is accessing it, you'll need to use


http.get来访问它。



http.get to access it.

app.controller("YourNameForController", ['


scope','
scope', '


这篇关于如何在anguarjs中连接REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆