in Angular the service.ts is also transposed and executed in the browser even though it does not have an html attached to it?

Asked

Viewed 74 times

0

my doubt is about the angular security and business rules, I can leave some kind of business rule at the angle at least in service.ts because the service is running on Node and does not have an HTML attached to be interpreted in the browser, I have this doubt, can anyone answer me ? and a conceptual doubt even.

1 answer

0


html, css and javascript are executed in the browser.

All code you write in the angular will be transferred to html, css and javascript and will be executed in the browser.

Transpilation occurs only when switching from typescript to javascript (pq the browser does not understand typescript or the syntax of the framework). Angular compiles your files, minifica, joins into a file or some and is ready to run in the browser. The service is a js file and will run in the browser.

Any code you write can be seen by someone in the source tab of F12, but when you build for production, angular changes the name of the variables, minifica and do a series of steps regarding security. https://angular.io/guide/security

Here shows basic concepts https://angular.io/guide/architecture how the visualization layer works, data link between a template, component and so on...

  • What you’re telling me is that there’s no safe way to leave a code on the angular, is there? i see api’s in backend on NODE so these API’s can’t use correct angular ?

  • Angular is a web framework for front-end, your files run in the browser. Node is a platform to run on the server, it is not possible to create angular api (pq it is a framework to run in the browser). You create api’s with Node, java, . net, ruby... which provide data for the front end to access. They talk via JSON

  • It makes no sense to leave sensitive data in a front-end application, because everyone can access your application... But if still necessary, angular can be executed on the server side (it is called Universal Angular) https://angular.io/guide/universal. But it is a slightly more advanced theme... Abs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.