Skip to content

gertcuykens/decorators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Polymer 2.x decorators

Polymer 2.x typescript decorators example.

Install

bower install

Compile

tsc

Example

http-server -o

Use decorators.js

import {customElement, property, query, queryAll, observe} from 'decorators';

@customElement('test-element')
export class TestElement extends Polymer.Element {

    @property({notify: true})
    aNum: number = 42;

    @property({notify: true})
    aString: string = 'yes';

    @property()
    aBool: boolean = true;

    lastNumChange: number;

    lastMultiChange: any[];

    @query('#num')
    numDiv: HTMLDivElement;

    @queryAll('div')
    divs: HTMLInputElement[];

    @observe('aNum')
    private _aNumChanged(newNum: number) {
        this.lastNumChange = newNum;
    }

    @observe(['aNum', 'aString'])
    private _numStringChanged(newNum: number, newString: string) {
        this.lastMultiChange = [newNum, newString];
    }

}

About

Polymer decorators.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published