- Keep your old code exactly as-is.
- Keep writing ES5.
- Add JSPM (+Babel +SystemJS) to your project
- Skip using JSPM for dependency management for now. Stick to what you're already doing.
- Get the tiniest possible ES6+ snippet working alongside your existing code
- Begin using ES6 modules to wire up new components that you write
- Slowly introduce new ES6+ syntax that you are comfortable with, verify the ES5 output
- Expand ES6+ usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('foo', []) | |
.config(function($provide) { | |
$provide.decorator('$rootScope', function ($delegate) { | |
// Shim needed for browsers I don't care about | |
var proto = Object.getPrototypeOf($delegate); | |
proto.$bar = function() { | |
// Do something | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Problem: When I have no control on some ajax or generated html and I need to wait for them. | |
@Solution: Set an interval to check my conditions and them execute a callback. | |
function waitFor ( options ) { | |
options = $.extend( {}, { | |
callback: function(){}, | |
condition: function(){ return true }, | |
interval: 100 | |
}, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
// author: Pawel Kozlowski | |
var myApp = angular.module('myApp', []); | |
//service style, probably the simplest one | |
myApp.service('helloWorldFromService', function() { | |
this.sayHello = function() { | |
return "Hello, World!" |