Friday, February 23, 2024
171
rated 0 times [  174] [ 3]  / answers: 1 / hits: 21153  / 8 Years ago, thu, september 8, 2016, 12:00:00

Is it possible to run an Angular 2 application in browser without using NodeJS as a server. I am not sure, but if i understand correctly the newest browsers are able to compile/understand the TypeScript code so i don't have to use any third part js lib to compile it into plain javascript?




I would like to create an application using 100% Angular 2 on frontend and for the
backend REST API using Ruby On Rails, without using Rails's page rendering, sessions etc..




I am little confused about it how does Angular2 work/run behind the scenes... How i should configure my Angular2 application to use it without NodeJS?


More From » ruby-on-rails

 Answers
8

I think you're mixing up some technologies here.



Server



You can run an Angular app on any server that can host static files. There is nothing special about node. So yes, you can use a ruby. Or an Apache, nginx, lighttpd etc.



The reason for this is that JavaScript is run on the client side. The server's response is only to deliver the JS/HTML/CSS files to the client that is visiting your site.



TypeScript



If you're writing an application with TypeScript you need to transpile it to JavaScript before any browser understands it. You can do this (1) before you're deploying your app to the server or (2) use a library like System.js that will transpile TypeScript on the fly.



While (2) is definitely an option and the Angular CLI used it until recently, (1) is in my opinion the better option. Angular CLI switched to (1) and is now using webpack. Webpack is transpiling and bundling your app before it is hosted on a server.



Hope I could clear things up a bit for you.


[#60768] Tuesday, September 6, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daryldeontaeh

Total Points: 46
Total Questions: 97
Total Answers: 105

Location: Maldives
Member since Sat, Jan 29, 2022
2 Years ago
;