What sort of features does Angular include?
- It’s a component-based framework for building scalable web applications.
- TypeScript has a collection of well-integrated libraries that cover a wide variety of features, including routing, forms management, client-server communication, and more
- TypeScript has a suite of developer tools to help you develop, build, test, and update your code
With Angular, you’re taking advantage of a platform that can scale from single-developer projects to enterprise-level applications. Angular is designed to make updating as easy as possible, so you can take advantage of the latest developments with a minimum of effort. Best of all, the Angular ecosystem consists of a diverse group of over 1.7 million developers, library authors, and content creators.
What can we do with Angular and Delphi?
Of course many things we can do using Delphi, one of them is by serving Angular application using it, so let’s create simple web application using Angular. Here are the steps:
Install Angular CLI
npm install -g @angular/cli
Create new Application using it
ng new web
You can read full tutorial on their website here
if everything is smooth, now you can run the application using below command
ng serve --open
But wait, we will not run Angular Application using their own embedded HTTP server. so run below command to build the application
Now there should be a Dist folder.
We need Horse Middleware to serve static files. Download here https://github.com/CachopaWeb/horse-server-static
Now horse1.dpr code looks like the following:
index in 'approutesindex.pas',
employee in 'approutesemployee.pas';
with THorse.Group.Prefix('/apis') do
THorse.Listen(8080, procedure(Horse: THorse)
Writeln(Format('Server is runing on %s:%d', [Horse.Host, Horse.Port]));
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
You can serve up the Angular web pages with this code..
You will need to copy the folder dist/web to Win32/Debug, first though to run it in the debugger since our Horse application build to win32
Running Angular with Delphi
Run application and point your browser to
http://localhost:8080/index.html , you should see something like the image below:
Easy isn’t it ? Please check updated code here https://github.com/checkdigits/horse-API-Demo