Skip to content

Commit

Permalink
Version 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GabiAxel committed Jul 1, 2015
1 parent 4975976 commit dad9eac
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 272 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Changelog

## 0.3.0 - 2015-07-01
- Upgraded to Polymer 1.0
- Simplified mapping structure
- Dropped observe-js dependency in favor of native Object.observe()
- Reimplemented object and array observation for changes
- Use property-changed event for primitives and reference changes
- Added/updated built-in support for Iron, Paper, Gold and Google elements

## 0.2.0 - 2014-12-10
- Upgraded to Polymer 0.5.1
- Removed mapping for core-input, which now works out of the box
- Added mappings for core-selector, core-menu and paper-action-dialog
- Removed handling of automatic bootstrapping, which is not needed for bleeding edge browsers (Chrome and Opera)
- Changed extension point to use AngularJS constant instead of a global variable
- Changed extension point to use AngularJS constant instead of a global variable
93 changes: 1 addition & 92 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,3 @@
# ng-polymer-elements

## Introduction

Web components make is possible to write encapsulated pieces of view and logic independently from any framework. The Polymer project contains a platform for pollyfilling and writing web components, and two sets of web components: core elements and paper elements.

Although there are many similarities between the ways AngularJS and Polymer implement two-way binding, it's not possible to use two-way binding of AngularJS model with web components out of the box, and even one-way binding is limited only to strings.

ng-polymer-elements overcomes this by applying directived to Polymer web components, and each directive is in charge of mapping attributes that reference AngularJS models to the web component's properties.

For example, the following code binds the scope's "myText" property to Polymer's paper-input "inputValue" property using the ng-model attribute, very similarly to how it looks for a basic text input:

```html
<paper-input ng-model="myText"></paper-input>
```

## Installation and Bootstrapping

The project is available through Bower: `bower install ng-polymer-elements`

Add the script `ng-polymer-elements.js` or `ng-polymer-elements.min.js` to your page.

**Important** : In older browsers, AngularJS should be bootstrapped only after the custom elements have been registered, and therefore you can't use automatic bootstrapping (ng-app="..."). You need to call angular.bootstrap() only after Polymer has been loaded, and with a wrapped DOM element:

```javascript
function bootstrap() {
angular.bootstrap(wrap(document), ['myModule']);
}

if(angular.isDefined(document.body.attributes['unresolved'])) {
var readyListener = function() {
bootstrap();
window.removeEventListener('polymer-ready', readyListener);
}
window.addEventListener('polymer-ready', readyListener);
} else {
bootstrap();
}
```

This is not needed if you are only targeting the latest Chrome and Opera, where you can simply use:

```html
<html ng-app="myModule>
```
Also add the ng-polymer-elements module to your application dependencies:
```javascript
angular.module('myModule', ['ng-polymer-elements']);
```
## Available Component Support
The following Polymer elements are support:
- [core-list](http://www.polymer-project.org/docs/elements/core-elements.html#core-list)
- [core-menu](http://www.polymer-project.org/docs/elements/core-elements.html#core-menu)
- [core-overlay](http://www.polymer-project.org/docs/elements/core-elements.html#core-overlay)
- [core-selector](http://www.polymer-project.org/docs/elements/core-elements.html#core-selector)
- [paper-action-dialog](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-action-dialog)
- [paper-checkbox](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-checkbox)
- [paper-dialog](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-dialog)
- [paper-input](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-input)
- [paper-radio-group](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-radio-group)
- [paper-slider](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-slider)
- [paper-tabs](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-tabs)
- [paper-toast](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-toast)
- [paper-toggle-button](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-toggle-button)
See [documentation](http://gabiaxel.github.io/ng-polymer-elements/) for usage examples.
## Supporting Additional Components
ng-polymer-elements uses a simple structure to map directive attributes to custom element properties. You can extend the mapping by setting the `$ngPolymerMappings` constant in the `ng-polymer-elements` module with your mappings.
The mapping structure is an object where the keys are the directive names, and their values are objects that contain a key for each directive attribute you want to map. The values for the directives are objects containing a single entry where the key is the type (`primitive`, `array`, `object` or `event`) and the value is the custom element property.
```javascript
angular.module('ng-polymer-elements').constant('$ngPolymerMappings', {
newElement: {
anAttribute: {
primitive: 'an-attribute'
},
anEvent: {
event: 'an-event'
}
}
});
```
In this example we add support for new-element and map an-attribute as a primitive value an an-event as an event. When mapping events, the original event will be available to AngularJS handlers as the $event parameter.
See `allMappings` in [ng-polymer-elements.js](https://github.com/GabiAxel/ng-polymer-elements/blob/master/ng-polymer-elements.js) for default mappings.
[Documentation and examples](https://gabiaxel.github.io/ng-polymer-elements/)
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-polymer-elements",
"version": "0.2.0",
"version": "0.3.0",
"authors": [
"Gabriel Axel <[email protected]>"
],
Expand All @@ -17,8 +17,8 @@
"tests"
],
"dependencies": {
"angular": "~1.3.0",
"polymer": "Polymer/polymer#~0.5.1"
"angular": "^1.4.0",
"polymer": "Polymer/polymer#^1.0.0"
},
"devDependencies": {
}
Expand Down
Loading

0 comments on commit dad9eac

Please sign in to comment.