AngularJS - Do I need lots of API's? [closed] - angularjs

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am wondering if I will be needing a lot of API's for my angular application. This is a broad statement so let me explain a few things.
Lets say that on my page I have three selects (dropdown lists).
Fruits, Vegetables, Produce
They all have their own data,
Fruits (ID, Name, Importer Order Number, Importer Name).
Vegetables (ID, Name, Distributer ID).
Produce (ID, Name, Manufacturer Name).
So if I want to populate each of these select statements, will i have to make 3 seprate API calls? Or should I be making 1 API call returning each of these? Is it possible to make 1 API call to return all this data?
If so does anyone have a simple example?
I want to know whats best practice...
Thank you!

The answer is depend on what you want to achieve, if you want a full dynamic Ajax application the answer is Yes.
Referring back to your question and scenario, if the data on the HTML element required dynamic change while attending the application then you need a separate call for each element. If the data on the HTML element doesn't require dynamic change then you can put your data into single Master Model and bind the sub object of the Master Model for the required HTML element.
As example, a single Select HTML element wont required a dynamic change, but a component of Autocomplete Select might require a independent call due to large database call and filtering process on back-end.

Angular is a framework that enables you to create rich client applications for web browsers.
When you make a request to a server from a modern framework such as Angular, you are typically doing one of two things:
Requesting static resources such as html templates (partials), images, css, js, etc.
Requesting data, usually prepared as a REST request, and typically returning a string that is in JSON or XML format. This is no different from a typical AJAX request made by most common web applications today. Angular does provide a service for obtaining an HTTP client, but it's not proprietary by any means.
Your question refers to the design of your REST API, and has nothing to do with Angular the framework.
With that said, there are plenty tutorials on REST best practices. And here is an article on what to avoid when designing REST services.

This depends entirely on your backend script. It does not matter if you are using Angularjs, jQuery or plain XHR.
For example, I often use PHP. When I want to reduce the total number of API calls, I write my PHP script such that it returns a single JSON object that contains multiple 'columns' of data.

Related

What is the best way to develop Micro Front-end web app while hosting the micro front-ends independently [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have tried,
Single SPA
Web Components
But in both ways, i couldn't find a way to develop and deploy the Micro Front-ends separately and then refer those deployed micro-front ends in a wrapper web app.
In the examples i tried using the above methods, the micro front-ends are rendering in the wrapper web app but when served independently, they are not rendering as expected.
You can't do this with a plain static site solution. You have to use some back-end. The issue is that you need to provide a list of micro-frontend-applications (mfa) dynamically, so you have to alter at least something.
The simplest way to achieve this would be:
Create a script (lets name it Loader) that knows how to load scripts dynamically (see document.createElement).
Create an API endpoint that will return the list of scripts, that should be loaded. (here back-end appears)
Update Loader to use API to get the list of micro frontends you want to load.
Now, your the schema should be like this:
--> Index.html started
--> Loader do fetch for the list of the mfa scripts
--> Loader adds listed scripts dynamically
--> Applications start working
When you need to change the list of apps, you don't need to redeploy anything. Just change the API response (by updating the DB, config, or whatever you want) and it will work.
This is not ideal (very not ideal from a performance perspective, but will work for the plain static site).
The better way (if you have a back-end) is to generate the page on the fly and embed your scripts with applications dynamically on the server-side. It is much simpler and might be faster, cause you don't need to wait for a call to the API to get the mfa list.
Hope this helps.
P.S. Using dynamic script loading might be dangerous. If you decide to do the first way, don't forget to verify that all scripts are trusted. You might use Content-Security-Policy for example.

create a searchable database of word documents [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
At work we have a large amout of processes which are laid out in several different Word documents. Some as large as 30mb and they include screenshots. What I would like to do is create a front end using in order to be able to search all of them simultaneously and have autocomplete to suggest which part of the process to go to. I've looked at various ways of doing this but it seems I would have to put all the Word document data in to a database to make it work and that would have the disadvantage of not being able to see the screenshots. Is the best way to compile all of the processes in to one Word document then search that somehow or would I need to export the different sections in to a database but how would I then make the screenshots visible? The other way I was thinking was making each part of the processes in to a seperate page which I could call via bootstrap as I have a rough idea of how to structure the data. The problem is this would be very laborious and I'd prefer if there was a way of categorising it by some automated process or script. Any ideas welcome. The method I would like to implement is a single web page which I could store locally and everyone could access implemented using Ajax.
This seems to be off topic, based on the subject...
but at first glance, A simple media-heavy Filemaker database could be made in 30 minutes, and you could implement .pdfs of the Word files as well as full text content, for quick lookups.
The added advantage would be that you could access it via iOS, Mac, or PC....
This option could easily allow thumbnails as well as full documents (.doc or .pdf) either inserted or attached to the file, and available for download if preferred..
The only component of prep which could take time would be actually cutting .pdfs from each Word file to attach for easy viewing...
You would then reference the text in each file in one record field, view the thumbnails in another, and download (or read) the whole document in another. Filemaker allows numerous views of any record, and this can all be accomplished quickly in a single layout.

Creating custom order system [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
The question i have is many fold.
So I work IT for this company. It’s a small company. Very small. They have an ancient ordering system that uses MSACCESS and was built in Visual Basic. I’ve been tasked with developing a new ordering system that processes orders as well as take in orders online.
I’ve created an order form in Excel with all the proper calculations that need to be made as sort of a foundation. I’ve found a service called SpreadsheetConverter that converts it to HTML or if I’d like Node.JS. But to be completely honest I have no idea what to do with Node.JS. I have some knowledge of VB and i’m (sort of) starting to understand databases.
My question is where would the best place to start if I wanted to build an application that can take in orders, store/retrieve customer data (autofill?), store order information into a database so i can retrieve them. The order system has to customly tailored to this company, they make Doors, so the calculations deal a lot with sizes and styles.
I have all the calculations i need. Basically where should i start if I want to build a UI, write simple code, and have it interact with a database. I’ve checked out Xojo, I have a Mac so i cant use Visual Basic. Where should i look to start a database?
Or is it possible to connect the Node.JS that spreadsheetconverter creates and connect it to something like Firebase?
I’m sorry if this all seems confusing, I basically don’t know where to start and a push in the right direction is all i need so i can narrow my focus.
Xojo might indeed be a good start for this.
Xojo includes access to a sqlite database, and you can add new records rather easily. You do need to know how to design and query an SQL db, though.
The biggest question is probably how to implement the user interface. This will be the biggest task. With Xojo, you can design it fairly easily, using its window layout editor.
Then you can either develop a monolithic desktop app, i.a. a Mac or Windows app that runs and maintains its database all on the same, single, computer. Or, if you want to allow multiple users access the database from different computers, consider writing a Web application in Xojo, which will be used through a web browser then. Most code will be the same, but testing will be a bit more complex and slower for a Web app, probably.
You would have to re-implement all your calculations in Xojo, though, as Xojo has no way to use or import Excel sheets this way.
Also, have a look at FileMaker. I have never used it but it may fit your needs.

Can Angular JS be the replacement for template engines like EJS or Jade? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am new to MEAN stack. I have seen Template engines being used while developing node JS apps and realized it can be used to make static documents dynamic by integrating values from server.
However, I see Angular JS facilitates same stuff. Then why use template engines ? Is it absolutely necessary to use them? Can angular completely replace them ?
I think you're on the right track simi. When starting with Angular it is tempting to do "double templating" - templating on the server side and on the client side. Unless you absolutely need the server to render HTML your server should just be an API, the usual REST services serving JSON. Expose an API and treat your Angular application like any other client (Android, iOS). To see an example of this approach in action check out the Angular Fullstack Yeoman generator.
There are valid reasons to want the server to render full HTML responses, SEO probably being the most common. Whether or not it is worth the extra effort is a design decision.
As with all questions that are "this" or "that" the answer is "it depends".
First of all they aren't exclusive, so there isn't a reason to choose between them, but you should try to use them in a predictable way in your code base
Server side templates are good because it's generally less complex and it reduces client compute costs. If a part of your page doesn't need to be dynamic on the client side, it's a good candidate for EJS. An example might be a dynamic menu in a CRM application where you'll only change the content with config updates.
Angular (and other client-side MVW frameworks) offer lots of great things really. The first immediate benefit is that you can easily load dynamic content on the client side, which can result in better responsiveness and reduce the complexity of the backend (assuming you already needed an API layer, you can get a lot of stuff for free). A good example would be an auto-refreshing homepage feed which reloading the whole page is a waste. But most of that we've had for a long time with AJAX. Angular also makes it easy to generate the template so you can, once again, write less code and (if done right) more readable, testable code.
I think the right answer is to use both as you see fit.
NO. Angularjs cannot be the replacement for template engine like EJS or Jade. You need to use any one of the template engine. If you like ejs templating engine then you may use your angularjs code inside that template. Just suppose this is your regular html and you're including angularjs in it.

Can AngularJS be used only in context Of SPA(Single Page Application)? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
i have just started learning AngularJS and build a project using AngularJS ,Spring and Hibernate ,this project was an SPA(Single Page Application) and i have used REST interaction with server.Now i have another project to work on and using AngularJS would make the develoment of this project easier but this project is not an SPA and using REST would also make it manageable, i want to know for what requirements we switch to AngularJS , is it that only to make an SPA ?
Absolutely not. AngularJS has full support for the SPA concept (e.g. routing), but can be used to create individual pages in a larger app (or a small app for that matter) that have no direct relationship to each other.
AngularJS fits in nicely with server side frameworks (e.g. ASP.net MVC) which can be used for server-side routing and to render the initial page template. Angular can then take over once the initial page is loaded.
I have personally done this on several projects with great success.
It is true that Angularjs helps us to make great Single Page Application with less effort. Instead Angularjs can be used for normal webpage development. Angularjs can provide following advantages:
Reduces amount of code, as Angularjs extends HTML page: Angularjs provide various in-built directive that helps code duplication. It also provide facility to create our own directive.
Two-way Binding
Dependency Injection
Provide Rest Support apart from Single Page Application
Template Features
Edit:
All this above features can be used in multiple page of your Web-Application, that you are working on.
More Info

Resources