This is an introduction to my angular starter project, explaining what it is, what it contains, and why it was built.
This project is a fork of angular-starter, changing it a little bit, and adding some more features and samples to it.
Why Angular 1.x?
It’s true that Angular 2 is now all the rage. However, I think that there are still valid reasons to be starting a new project with Angular 1.5:
- Even though it seems like it’s been around forever, Angular 2 is still, currently, not released yet.
I’ve heard the angular team say that there are plenty of applications built on Angular 2 beta running in production, but there are many (including me) who wouldn’t use anything pre-release in production.
- Even after it’s released, the resources and help you can get for Angular 1.x are much much better than for 2.0.
Even though the angular team has done a great job in churning out documentation for version 2, you’re still likely to struggle to find answers and non-trivial examples for angular 2.
This is especially relevant for those who want to create a non trivial angular app that’s more than just forms and CRUD; they will struggle to find examples and solutions for complex problems in angular 2.
- There are many teams with existing skills in angular 1. For them, the learning curve of angular 2 might not be worth the switch (obviously, depending on the expected scale and lifetime of the project).
Why another startup project?
True, there are already many. However, I wasn’t able to find one that answers all of my requirements:
- Modern (i.e using ES2015 and angular 1.5 with components)
- Production-ready (webpack configuration for release)
- Follows best practices
- Non-trivial (provides working examples of more advanced use cases)
The original angular-starter project covers the first 2 points very well, however – I felt it could be improved in the latter 2 categories.
What it is
Obviously, this project uses the babel transpiler and webpack modules, which allows you to use ES2015 features , as well as angular 1.5, and SASS compilation.
It also contains example code for using angular’s new
this is currently the recommended way to write angular 1.5 apps (at least until next week, when something better comes along :p ), and I’ve yet to see a starter project that features examples for all of these.
Twitter bootstrap and FontAwesome have already been included, since they’re so widely used.
(If you’re not interested in using them, it’s as easy as simply removing them from the
package.json and from your
The project’s build script is already configured to concatenate, uglify, and minify your code, with cache busting, ready to be served in production.
resources directory is copied as-is to the production build, so that’s the place to keep your resources (i.e images).
Follows best practices
Sadly, John Papa hasn’t updated his famous angular 1 style guide to include ES2015 or components.
Thankfully, Todd Motto has stepped up with his own style guide covering modern angular 1 apps. My project tries to follow that guide, especially module structure.
Linting: The project comes with linting using ESLint, and is pre-configured to use the recommended rules.
You’re encouraged to add or modify to them (in the
.eslintrc file) as appropriate for your team.
I found that many samples and starter kits don’t contain any examples of using dependencies, or testing any type of realistic scenario.
This is why I’ve added the
home component, which uses a service as a dependency, and has a route that leads to it.
This allows you to see an example of routing to a component, and of using dependencies and the
In the tests for this component, you can see how to mock its dependencies using the
$provide provider, and how to test using a mock that returns a
I’m also using the
inject function to obtain a reference to the
$componentController, which is used to create instances of components that you can run tests against.
To understand more about mocking and testing, I recommend reading the jasmine docs.
I’ve tried to create a starting point that is ready to go.
The idea is to allow developers to clone this starter project, and immediately start writing their application code, without having to spend any time configuring frameworks, tools or dependencies.
I’m completely comfortable with taking this project and starting to build a production application with it (in fact, I have done this), and I hope that others will find it useful as well.
If you have any comments or ideas for improvements (hey, I’m just learning as I go along..), feel free to open an issue (or even better – a PR) on the repository.