Giter VIP home page Giter VIP logo

angular-elements-example's Introduction

Angular Elements Example

This project was created to test out Angular Elements.

In order to demonstrate that this project has a html page with Bootstrap 3 and jQuery and a 'part' of the page running Bootstrap 4 and ng-Bootstrap. This is done by using Custom Elements (also called Web Components) to isolate the new functionality from any existing CSS / Javascript.

It shows that you can have a legacy website and upgrade it incremetally instead of having to do a rewrite from scratch.

Here is a link to the running project.

Building Angular Elements

  1. ng build --prod --output-hashing none
  2. node build-elements
  3. http-server dist/angular-elements-example
  4. http://localhost:8080/index-elements.html

Browser Support

It was tested on Chrome, Firefox, Edge and Safarri. I didn't add support for Internet Explorer 11, it can be done but the cost v benefit just didn't add up for me...

Installed Packages

The project was generated with Angular CLI version 8.3.18.

  1. Create Project ng new angular-elements-example

  2. Angular Elements ng add @angular/elements

  3. Scripting Libraries concat and fs-extra npm install concat --save-dev npm install fs-extra --save-dev

  4. Install Polyfills n.b. Shady DOM didnt work from a pollyfill for some reason although it was suggested it would here.

    4a. Add to pillyfills.ts: import '@webcomponents/custom-elements/src/native-shim'; import '@webcomponents/custom-elements/custom-elements.min'; npm i @webcomponents/custom-elements --save

    4b. Remove the script from angular.json "input": "node_modules/document-register-element/build/document-register-element.js"

  5. Bootstrap 4 & ng-nootstrap npm install bootstrap@4 --save npm install --save @ng-bootstrap/ng-bootstrap

Http Server

The npm package http-server is a lightweight ummmm... http server. npm install http-server -g

Commands

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Run ng test to execute the unit tests via Karma.

Run ng e2e to execute the end-to-end tests via Protractor.

angular-elements-example's People

Contributors

joelviney avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.