Video: Build an Angular 2 Dashboard using Wijmo

Hello Everyone! In today's video we'll look at how to build an Angular 2 dashboard in under five minutes. If you haven't watched our Getting Started videos, I highly encourage you to do so as this will walk you through project setup.

Transcript

Hello Everyone, welcome to the building a dashboard using a shared dared data service with Wijmo and Angular 2. I am Ross Dederer, developer relations at GrapeCity. Let’s begin by creating a new application in Visual Studio 2015. I am going to name my project DashboardNg2. If you haven’t already I encourage you to check out our getting started videos. Add a new component to our src folder. This will require two files, an app ts and app html file. Inside App ts import the angular 2 libraries. For this dashboard, we will use a Wijmo input, Wijmo FlexChart, and Wijmo FlexGrid. So let's import those modules as well. Finally, let's import our Data service. Configure our component decorator selector with app, templateUrl to point to app html and import our CORE_DIRECTIVES. Next, we need to import our Wijmo input directives of combo box, a few from FlexChart, and a few from FlexGrid. Now let’s build our class and give it a default constructor. To complete the app ts structure, let's assign a root component of AppCmp and expose our Data service to it. Add a new Typescript class and call it DataSvc. This will be our shared data service. We need to import an injectable from Angular 2. Now let’s build our class. Inside our class create a getData function that returns an array. We can use a for loop to complete the model. I am going to give my getData function a simple string parameter to customize the data request. Back in our AppCmp class let's declare countries as a string. We can declare our data property a type of Wijmo.CollectionView. In our default constructor we need to inject DataSvc as a property type and then assign dataSvc to it. We need to initialize dataSvc to our parameter from our constructor. Visual Studio is going to point out my error here. Finally, we can instantiate data as a new Wijmo.CollectionView passing it our array from our dataSvc. Finally, we need to construct our view that will contain our three controls. Lets add a combo box bound to data displaying the country field. Add a FlexGrid bound to data and define each column manually in our markup. Lastly, add a FlexChart bound to data defining each of our three series manually. Set our default.html page as our start up page. Last but not least, add our component selector element to our main body. If we run the application, we can run through our dashboard. As we change the combo box value, the selected item in the grid updates. If we want to update values in our Grid, our Chart will update automatically. Thanks for watching. Learn more at Wijmo.com/angular2.