Upload file in Angular 2

In this tutorial we will discuss how to upload file in Angular 2.

Here is the view of uploading file. There is an option to browse the file as you select the file fileChange function will be called which is written in FileComponent.


Create a component :

html :                                                                                                                                     

In this component I have written fileChange function which calls the service to upload the file. But before calling the function we create the FormData object and then append the file object into FormData object. ...  Read More

Share This:


Export data to CSV with headers in Angular 2

Sometime we need to export data in CSV. Here I'm going to explain how can we export the data to CSV in Angular 2 along with headers.

Data which will be exported will be received form web service on and click event.



First of all you need to install angular2-csv library by following below command.

Install:

Html:

Component:

 

 ...  Read More

Share This:


Generate PDF in Angular 2




First of all you need to install following javascript libraries:

Then add following in angular-cli.json:

Create a component

html:

component ts:

Share This:


Cannot find module 'underscore' || install underscore module in angular 2

You need to install that libraries typings definitions in previous versions, if you want to use an JS library in TypeScript.

In newer version of TypeScript uses @types system. So now you don't need to install typings manually, you can just write this. For first install

And then

Share This:


Setup angular2 local development environment

1) Install node js
2) sudo npm install npm -g // install NPM
3) sudo npm install -g typescript // install typescript
4) git clone https://github.com/angular/quickstart.git quickstart // cloning angular2 setup
5) cd quickstart
6) sudo npm install
7) sudo npm start

Via CLI

1) Install node js
2) sudo npm install npm -g // install NPM
3) sudo npm install -g typescript // install typescript
4) npm install -g @angular/cli
5) ng new my-app
6) sudo npm start

Share This: