This project demonstrates the basic usage of generator-angular-polymer for Angular CLI version 1.0.0.
- Install generator-angular-polymer.
- Get the code:
git clone https://github.com/pfecht/generator-angular-polymer-demo.git
. - Install the dependencies: run
npm install
. - Install Polymer elements: run
bower install
insrc/assets/
- Run the generator:
yo angular-polymer
in the project root directory. - Run
npm start
for a dev server. Navigate tohttp://localhost:4200/
. The app will automatically reload if you change any of the source files.
Polymer and its elements are located in src/assets/
:
- The core library and external elements are managed with bower.
components/
contains custom Polymer elements.elements.html
sums up all Polymer elements which should be part of the application.
To integrate them in angular-cli, elements.html
is included in two files:
src/index.html
to add them to the Angular application.yo-rc.json
to configure them for the generator.
Finally, the angular-cli.json
has been changed to add the polyfill:
{
...
"apps": [
{
...
"scripts": [
"assets/bower_components/webcomponentsjs/webcomponents-lite.min.js"
]
...
}
The generator is configured in .yo-rc-json
and automatically recreates the directives since he is part of the package.json
:
"scripts": {
"ng": "ng",
"start": "yo angular-polymer && ng serve",
...
},
src/app/shared/polymer-elements/
contains the generated directives.
AppModule
(src/app/app.module.ts) includes the generated directives:
...
import { POLYMER_ELEMENTS } from './shared/polymer-elements/index';
@NgModule({
declarations: [
...
POLYMER_ELEMENTS
],
...
})
export class AppModule { }
Apache 2.0