Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
angular decorate
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
damienklinnert
April 09, 2014
Programming
1
84
angular decorate
Use AngularJS' decorate function with ease
damienklinnert
April 09, 2014
Tweet
Share
More Decks by damienklinnert
See All by damienklinnert
Angular Performance Tuning
damienklinnert
4
270
Angular Performance Talk
damienklinnert
0
130
Fight the Rot - Refactor stinky JavaScript
damienklinnert
0
180
modern web apps
damienklinnert
0
120
Become a node package maintainer
damienklinnert
1
90
bootstrap single page apps
damienklinnert
1
310
test your nodejs code
damienklinnert
5
360
Other Decks in Programming
See All in Programming
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
160
登壇資料を作る時に意識していること #登壇資料_findy
konifar
3
910
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.4k
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
100
CSC307 Lecture 02
javiergs
PRO
1
770
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
540
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
190
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
480
Grafana:建立系統全知視角的捷徑
blueswen
0
320
Apache Iceberg V3 and migration to V3
tomtanaka
0
150
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
250
Featured
See All Featured
Music & Morning Musume
bryan
47
7.1k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
400
Building Adaptive Systems
keathley
44
2.9k
Leo the Paperboy
mayatellez
4
1.4k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
96
Done Done
chrislema
186
16k
WENDY [Excerpt]
tessaabrams
9
36k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2k
The Pragmatic Product Professional
lauravandoore
37
7.1k
sira's awesome portfolio website redesign presentation
elsirapls
0
140
Docker and Python
trallard
47
3.7k
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