Some time ago, Angular team introduced a CLI (Command Line Interface) tool for Angular2. It was created to help in development of ng2 applications. It can initialize a fresh app and serve it. It also has a support for webpack, so you can use it to build your applications. Today, I will like to have some play with it and show you how to make some use of this tool.
Have you ever wanted to create a custom dashboard from the data on your Google Analytics account? And for the dashboard to be publicly available? I recently wanted to add a “Top Posts” box on this blog. The problem is, it’s based on Jekyll, so is statically generated. I could have created some kind of plugin for jekyll (or maybe there is one), but I thought it would be cooler to get this data directly from GA. Obviously, you need to be logged in to access the Google Analytics API, which makes it impossible to use on a webpage. However, I have found Google Analytics superProxy. Today, I would like to show you how you can easily create an API with your GA data.
In the last post I have shown you how to split your application into modules. The problem with single-page-applications is the amount of scripts you have to load to the browser to show the first page. With standard configuration you’re loading all the framework files, libraries etc., plus your whole application. Even to display a simple homepage, the browser is getting all your components, templates, services. Today you will learn how to setup your modules so that they are only loaded when needed.
Angular2 introduces the concept of Modules (NgModule). Every angular2 application need to have at least one module, conventionally named AppModule. As the name suggests, module groups a part (or a whole) of application into a unit, which is easier to maintain. In this post I would like to show you, how modules work, how to split your application into modules and how to add a shared module with common components.
Angular2 comes with some predefined pipes. For those of you, who don’t know, pipe is a tool, which allows you to modify output of a property in the template. For example, to format date, price etc. Today, at work I had to come up with a solution, which would allow me to have a
DatePipe, which format is configured in the application settings - based on a currently selected translation. I could write a new, custom DatePipe, but why should I invent a wheel. I decided to extend the
DatePipe, which is coming with the angular and change its behaviour to suit my needs. It wasn’t as straight forward as I thought it would be, so I am writing this post in case someone else has the same idea.