Standards for the new web.
Everything is an element!
core-elements
et paper-elements
)
- {{item.label}}
- {{item.label}}
AngularJS | Polymer | |
---|---|---|
powerful | simple | |
reliable | not as much | |
mature | not yet |
a Controller is a JavaScript constructor function that is used to augment the Angular Scope.
myApp.controller('MyController', function MyController($scope) {
$scope.message = 'Hello!';
});
{{message}}
Nothing!*
* your own
Angular services are substitutable objects that are wired together using dependency injection.
A service is lazily instantiated singleton.
myApp.factory('myService', function myService(dep1, dep2, ...) {
// initialize service
return ..; // object or function
});
myApp.factory('myOtherService', function (myOtherService) {
// ...
});
myApp.controller('MyController', function ($scope, $http, myOtherService) {
$scope.message = 'Hello!';
});
Nothing!
myApp.filter('myFilter', function() {
return function( input, arg1, arg2, ...) {
// Transformation ...
return output;
};
});
{{ expression | myFilter }}
{{ expression | myFilter:arg1:arg2:... }}
PolymerExpressions.prototype.myFilter = function( input, arg1, arg2, ...) {
// Transformation ...
return output;
}
{{ expression | myFilter }}
{{ expression | myFilter:arg1:arg2:... }}
Directives are markers on a DOM element that transforms it or attaches a specified behavior to it.
myApp.directive('myDirective', function() {
return {
restrict: 'E', // restrict to element (E), attribute (A) or class name (C)
template: 'Template string with {{markup}} ...',
// ...
};
});
Custom element area just HTML elements!
{{profile.name}}
{{profile.title}}
AngularJS | Polymer | |
---|---|---|
Definition | complicated | simplified |
Usage | flexible | favors familiarity |
Maturity | mature | not yet |
Bad news!
There is no routing in Polymer.
Wait! That's not a bad news!
app-router ...
AngularJS | Polymer | |
---|---|---|
Routing | sucks! 1 | missing 2 |
1. ui-router
2. not really
You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc.
var myApp = angular.module('myApp', ['dep1', 'dep2', ...]);
var myApp = angular.module('myApp');
...
DOM is the module system.
* either Polymer or plain native WebComponent