--- title: Angular 2 order: 2 layout: page --- [[vaadin-core-elements.angular2]] = Angular 2 Integration While Vaadin Elements are built using Polymer, they also contain directives to enable seamless usage within Angular 2 applications. This page assumes that you already have an Angular 2 application setup ready. If you need help with the project setup, you should follow the https://angular.io/docs/ts/latest/quickstart.html[Angular 2 Quickstart] guide. == Installation Although Angular 2 dependecies are typically installed via https://www.npmjs.com/[npm], Vaadin Elements require installation with http://bower.io[Bower]. To install a Vaadin Core Element, you should run the following command in your project directory (replace the `[element-name]` part with the actual name of the element). [NOTE] Angular 2 support was introduced in `1.1.0-alpha1` versions of each element. Minimum requirement for the Angular version is `2.0.0-beta.16` or newer. [source,bash] ---- bower install --save vaadin-[element-name]#1.1.0-alpha1 ---- After the Bower installation is completed, you need to add the Web Components polyfill to the `
` section of your `index.html` file. [source,html] ---- ---- The Web Components polyfill will enable usage of HTML imports in your application. In order to have the newly installed Vaadin element available in your templates, you need to add an import for it. [source,html] ---- ---- Also the SystemJS configuration needs some modifications in order to load the modules correctly. Add the following `packages` entry for `bower_components` to your configuration unless it’s already present. [source,javascript] ---- System.config({ packages: { 'bower_components': { defaultExtension: 'js' } } }); ---- Before bootstrapping your application, you need to wait for the `WebComponentsReady` event. This event is fired after the HTML imports are done and the custom elements are upgraded and ready to be used. The following example demonstrates how to wrap your bootstrap code inside the event listener. [source,javascript] ---- window.addEventListener('WebComponentsReady', function() { System.import('app/main').then(null, console.error.bind(console)); }); ---- If you followed the Angular 2 Quickstart guide or you are otherwise using `lite-server` or `browser-sync`, create a file called `bs-config.json` in the root of your project folder with the following contents. [source,javascript] ---- { "snippetOptions": { "ignorePaths": "bower_components/**/*.html" } } ---- Now you’re all set to use the element inside your Angular 2 application. == Importing Import the directive as follows. This example imports the [vaadinelement]#vaadin-date-picker# element, but you should replace the path with the element you’re importing. Also the directive name should be replaced with a camel case representation of the element name. [source,javascript] ---- import { VaadinDatePicker } from '../bower_components/vaadin-date-picker/directives/vaadin-date-picker'; ---- Your Angular 2 component also needs to declare the usage of the directive. This can be done with the `directives` array of the `@Component` decorator. After the directive is declared, the element is available to be used in the `template` of your component. [source] ---- @Component({ selector: 'my-component', template: '