Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
angular decorate
Search
damienklinnert
April 09, 2014
Programming
97
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
angular decorate
Use AngularJS' decorate function with ease
damienklinnert
April 09, 2014
More Decks by damienklinnert
See All by damienklinnert
Angular Performance Tuning
damienklinnert
4
280
Angular Performance Talk
damienklinnert
0
140
Fight the Rot - Refactor stinky JavaScript
damienklinnert
0
200
modern web apps
damienklinnert
0
130
Become a node package maintainer
damienklinnert
1
110
bootstrap single page apps
damienklinnert
1
320
test your nodejs code
damienklinnert
5
370
Other Decks in Programming
See All in Programming
sbt 2.0: takeoff
eed3si9n
0
190
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
130
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
500
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
180
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
120
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
190
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
130
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.6k
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
6.1k
AI-Powered Domain-Driven Design
ziobrando
0
370
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
400
No More NoSuchMethodError
exoego
1
120
Featured
See All Featured
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
820
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
340
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
370
Unsuck your backbone
ammeep
672
58k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
960
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
440
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.7k
Building the Perfect Custom Keyboard
takai
2
940
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
Transcript
$PROVIDE .DECORATOR() MODIFYING THE BEHAVIOR OF ANGULARJS' CORE SERVICES
DAMIEN KLINNERT Software Engineer at Small-Improvements damienklinnert.com twitter.com/damienklinnert github.com/damienklinnert
THE DECORATOR PATTERN
None
THE COMPLEX WAY angular.module(moduleName, []) .config(function ($provide) { $provide.decorator(serviceName, function
($delegate) { // modify behavior here return $delegate; }); });
THE SIMPLE WAY angular.module(moduleName, []) .decorate(serviceName, function ($delegate) { //
modify behavior here return $delegate; }); www.github.com/damienklinnert/angular-decorate
ONE APPEND FILE EXTENSION IN $TEMPLATECACHE.GET()
What you have is: <div ng-include="'views/custom-template.html'"></div> What you want is:
<div ng-include="'views/custom-template'"></div>
// Decorator definition angular.module('$templateCache+get', ['ng']) .decorate('$templateCache', function ($delegate) { var
_get = $delegate.get; $delegate.get = function (key) { return _get.call(_get, key + ".html"); }; return $delegate; }); // Use decorator in whole app angular.module('app', ['$templateCache+get', ...])
TWO ADD BASEURL TO EACH $RESOURCE
Make this possible: var users = $resource('http://localhost/users'); console.log(users.baseUrl); // this
is new
// Decorator definition angular.module("$resource+baseUrl", ['ngResource']) .decorate('$resource', function ($delegate) { return
function (baseUrl) { var ret = $delegate.apply(this, arguments); ret.baseUrl = baseUrl; return ret; }; }); // Use decorator in whole app angular.module('app', ['$resource+baseUrl', ...])
THREE INSTRUMENT ANGULAR PERFORMANCE
What can you do with this? angular.module('$rootScope+instrument', []).decorate('$rootScope', function ($delegate)
{ $delegate.__proto__.$watch = function () { ... }; $delegate.__proto__.$apply = function () { ... }; return $delegate; });
THANK YOU RELATED MATERIAL angular-decorate www.github.com/damienklinnert/angular-decorate Hacking Core Directives in
AngularJS http://briantford.com/blog/angular-hacking-core.html Angular $provide http://docs.angularjs.org/api/auto/object/$provide