简体   繁体   中英

Angular 2 and Rails as a separate applications

Who can tell to me how to create a 2 separate applications: rails backend and Angular 2 frontend and config the data exchange between it. Rails app need to work as a json api. How Angular 2 understand recieved data from rails and how we can send the concrete data to concrete component?

Please some links, articles and so on.

Thank you so much!

The Server

I'm not an expert in the field of ruby, but this tutorial looked good to me: https://www.codementor.io/ruby-on-rails/tutorial/creating-simple-api-with-rails

The Client

Angular 2 belongs more to my strengths: Follow up to the official tutorial from google to develope an angular2 app. here is the link: https://angular.io/guide/quickstart If you really understand how that starter-tutorial works, you might use a quick-start npm package for a faster start. Be warned! You only use a quick-start package, if you understand the plain way angular 2 should be installed!

The Clients API engine

For the API queries between your client (angular2) and your server (ruby) use this tutorial: https://angular.io/docs/ts/latest/guide/server-communication.html

I would recommend you to develope only with TypeScript. Dont use EcmaScript (JavaScript) for your client! All the tutorials and the whole community are real hardcore typescript fanatics, so don't even try to convert them :D Just follow them! (To explain why, would take me another post...)

Good luck and have a nice start!

This is really at least two questions: 1) how can a static angularjs app consume json data 2) how can a rails server return json data. Both questions are best answered by simply learning the two frameworks. The harder questions are around designing the api and how to authenticate. All that is really too broad for a single answer except to say go and learn about those four concerns.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM