I'm new to Angular and am currently building a javascript heavy page that will have a frontend that is available to guests, and a user or admin area that is available to logged in users.
I also have a backend application written in PHP that provides me a RESTful API.
Now, I don't actually know how to structure my Angular app in order to avoid loading scripts in the admin area that are used only on the guest area and vice versa. My current project structure is the following:
web_root/
--app/
----css/
----img/
----js/
------controllers/
------services/
------app.js
------directives.js
------filters.js
----templates/
--index.html
In my index.html I load every javascript file separately. I don't know how to continue and build the admin area. Should I use another HTML file to load the relevant javascript files and another module?
Thanks in advance.
Why not just have separate controllers for guess and admin related sections? Then tie those up to different partials based on the routes defined in routerProvider? That way you can use the single app, consolidate reusable code into filters/services/directives but only load data for the requested view.
Related
Using example.com to represent my website, I would like users visiting example.com to reach a static website, but when they visit example.com/profile or example.com/dashboard, they will reach my Angular 12 app. I am using AWS EC2 to host my Angular app and my backend framework is Node/Nest, but it is just being used as an API (no routing, no possibility to use Angular Universal). I don't mind splitting up the landing page into a separate repo, but to the end user, the experience moving from example.com to example.com/home should be seamless. Any help is appreciated.
Note: This is a good suggestion Using Static HTML landing page with Angular app, however in my case, I cannot put my Angular app in a separate directory.
I need to simulate something similar to what I did for NestJS to customize a basic product for a specific customer.
For the backend, written in NestJS, I developed a feature that gets all modules inside a folder called "Plugin" and loads them inside the whole application at startup.
This is because my company sells basic software to N customers, but some of these customers may need more functionalities/customizations.
So at the moment I can provide more controllers/services by adding a folder inside the Plugin folder of my backend server.
By doing so I can have a unique repository of the backend where I can continue providing basic modules updates (the ones that every customer have).
The plugins are in a separate repositories.
Now I need to do the same thing for the frontends, so provide custom pages/components/navigation.
For the navigation it's not a problem, at frontend first load I can ask a JSON that tells me how to build/which elements are present inside the navigation sidebar.
But how can I provide the custom page (so HTML, TS, SCSS) connected to a menu item of the sidebar?
I'm looking for ideas on how to implement the following requirement.
I have 2 different applications one being a python Django app and the other one being a pure javascript app.
I can get both the apps running on different ports but I need to be able to integrate the js app into the Django app.
I.e. I want to add the js app into the Django app such that when you navigate to djangoapp.com/admin/js_app you go to the landing page of the js_app application.
the 2 apps are https://github.com/CodeForAfrica/gmmp
and https://github.com/OpenUpSA/wazimap-ng-ui
any ideas will be appreciated
Maybe you should go for a Hybrid deployment
All resources:
https://www.saaspegasus.com/guides/modern-javascript-for-django-developers/
Hybrid part:
https://www.saaspegasus.com/guides/modern-javascript-for-django-developers/client-server-architectures/#a-hybrid-architecture-in-practice
There are 2 ways as far as I know:
Add the js to each template of Django under tag. The core app is mainly served by Django
Use Django to serve the API only. The js app will call the API URL endpoints to get data. The core app is mainly served by js. This approach is mainly used by static sites like blogs, simple company sites, etc
I think you can only use a port as the entry point of your app.
yes definitely you can do you just add your javascript app in static folder of django and
Me and my team are trying to make a multi-page react app and each of us had been given one-one page to work on, for simplicity let us assume we have only 3 pages- I had to design login/sign-up, the other had to design the home page where the display information would be dynamically fetched from the API (let's call it the API page for simplicity).
I have made the login and sign up pages by keeping the HTML file as it is, and I have used react just to render the forms and perform form validation and account validation by hitting API in the backend in react, and I still need to call the /login.html page; whereas my friend has converted the whole HTML file into a react component, and he just renders the different components like sidebar, searchbar etc into one js file to display the webpage.
Which of the above is a better method to make a react webpage?
P.S- All the 3 pages are working absolutely fine independently.
How do we integrate all the 3 pages and also ensure that one is not able to access the API page unless and until he/she has logged in?
We are using webpack config to run our files.
I'm using Express framework on NodeJS (hosted by Heroku) to create my web site. I'm also using the React framework to create my components.
I have several HTML files with divs inside and React components which can be rendered in those divs.
When a user chooses a route (e.g. /movies) I want to be able to associate one HTML file with a component and return it back to the user. I already looked for a solution, but all of them talk about server-side rendering and sending back HTML files.
Is there another solution?
Check out react router you don't have to use server side rendering, you just need to give a react component that you want to return when a route is requested.
The standard way to do this now is to build a Single-Page applications and redirect all requests to /, and the front end routing will handle the required page to load.