• This repository has been archived on 10/Nov/2017
  • Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    TypeScript
  • Created over 7 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

experiments with Angular and Web Components

Sketching out hosting Angular Components as Custom Elements / Web Components

Angular Component API (4.x)

Angular components are

//annotate with metadata about template and styles
@Component({
  selector: 'my-component',
  templateUrl: 'my-component.html',
  styleUrls: [ 'my-component.css' ],
  viewEncapsulation: ViewEncapsulation.Native //Shadow DOM V0
  providers: [ SomeService ],

})
class MyComponent {
  //public API for component consumers
  @Input() someProperty:any; //property values passed in
  @Output() someEvent new EventEmitter(); //events go out

  @ViewChild(ChildComponent) childView:ChildComponent;
  @ViewChildren(ItemComponent) items:QueryList<ItemComponent>

  //bind to host element events
  @HostListener('mousemove', ['$event'])
  onMouseMouse(event:MouseEvent){}

  //bind to host properties and attributes
  @HostBinding('attr.aria-foo') someValue;
  
  //lifecycle events
  ngOnInit(){}
  ngOnChanges(changes){}
  ngDoCheck(){}
  ngOnDestroy(){}

  //view lifecycle events
  ngAfterContentInit(){}
  ngAfterContentChecked(){}
  ngAfterViewInit(){}
  ngAfterViewChecked(){}


}

Custom Elements v1 API

class MyCustomElement extends HTMLElement {
  //newable
  constructor(...optionalArgs?:any[]){}

  //attributes to observe changes to
  static get observedAttributes():string[]{ return ['value', 'foo'] }

  //properties
  someProp:string;
  set foo(value:string) { }
  get foo() { return 'foo' }

  //dispatch events
  onClick(){
    this.dispatchEvent(new CustomEvent('some-event', options))
  }

  //called when attributes change
  attributeChangedCallback(attributeName, oldValue, newValue, namespace):void {}

  //called when connected to a document / shadow tree
  connectedCallback():void {}

  //called when removed from document 
  disconnectedCallback():void {}

}

More Repositories

1

ng-universal-demo

TypeScript
256
star
2

ivy-code-size

Preview of Angular Ivy Renderer
JavaScript
162
star
3

ng2-application-shell

Angular2 Application Shell Architecture
TypeScript
76
star
4

ng2-electron

Angular2 + Electron
CSS
32
star
5

ng2chat

A Sails / Angular2 demo app
JavaScript
27
star
6

ngrxngconf

TypeScript
26
star
7

ng-webworker-demo

JavaScript
22
star
8

fluent_demos

demo code from reactive angular2 at fluent 2016
TypeScript
18
star
9

ng2-pwa-demo

TypeScript
15
star
10

ng2-pokedex

NG2 Implementation of pokedex.org by @nolanlawson
CSS
15
star
11

ng2-compiler-test2

TypeScript
12
star
12

ngrx-rest-app

A reactive Angular 2 application built with ngrx store
TypeScript
12
star
13

node-jwt-demo

simple demo of JWT auth w/ node.js and angular
JavaScript
9
star
14

oredev-angular2

Demo Code from Oredev 2015
TypeScript
7
star
15

ngnl_demos

Demo code from my keynote at NGNL 2016
TypeScript
7
star
16

ng-worker-dom

TypeScript
6
star
17

ng-worker-dom-demo

JavaScript
6
star
18

rx-slack

Reactive Extensions for Slack
TypeScript
6
star
19

ngrx-universal-state

sketching out ngrx state hydration via angular universal
TypeScript
6
star
20

innit-angular-sails-playground

Sandbox for hooking up sails and angular things.
JavaScript
3
star
21

jiffsync

React Native + HealthKit sketch
Objective-C
3
star
22

angular-labs-playground

Experiments Repo. Don't open issues about code in here.
Python
3
star
23

ng-rollup-dynamic-imports

TypeScript
3
star
24

gitrank

Sample GitHub API client app
JavaScript
2
star
25

sails-google-apps

Google Apps Adapter for SailsJS
JavaScript
2
star
26

ng2-hackernews-demo

TypeScript
2
star
27

rx-router

prototyping an rx based router for angular2
TypeScript
2
star
28

ng2reactive_talk

slides and code for angularremoteconf talk
2
star
29

angularSails-seed

angularSails seed project
JavaScript
2
star
30

reaxtor

Falcor + Rx + virtual-dom
JavaScript
2
star
31

ngc-loader

prototyping an ngc loader
TypeScript
2
star
32

compiler-bundling-demo

JavaScript
1
star
33

rx-socket-demo

TypeScript
1
star
34

FavorsApp-Ionic

JavaScript
1
star
35

ngsails-sandbox

Sandbox / Demo for all things angular + sails + waterline
JavaScript
1
star
36

ng2-webpack-demo

TypeScript
1
star
37

observable

EXPERIMENTAL typescript zone-aware implementation of es-observable spec
TypeScript
1
star
38

upgrade-demo

JavaScript
1
star
39

ng-lazy-aot-demo

TypeScript
1
star
40

npm-http-server

An HTTP server for files in npm packages
JavaScript
1
star
41

demo_app

Rails Tutorial 2 App
Ruby
1
star