Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing test #330

Open
wants to merge 262 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
262 commits
Select commit Hold shift + click to select a range
daa9ec6
NaNs
Jan 6, 2014
c7afc60
$eval - Evaluating Code In The Context of A Scope
Jan 6, 2014
abe73a9
$apply - Integrating External Code With The Digest Cycle
Jan 6, 2014
4b4a64c
$evalAsync - Deferred Execution
Jan 6, 2014
2ec56b1
Scheduling $evalAsync from Watch Functions
teropa Feb 22, 2014
aca75a7
Scope Phases
Jan 6, 2014
81fc2d1
Coalescing $apply Invocations - $applyAsync
teropa Oct 19, 2014
8968683
Running Code After A Digest - $$postDigest
Jan 6, 2014
909fb55
Handling Exceptions
Jan 6, 2014
4b04485
Watching Several Changes With One Listener:
teropa Sep 21, 2014
1ba29b4
Making A Child Scope
Jan 6, 2014
a84d494
Attribute Shadowing
Jan 6, 2014
062fe27
Digesting The Whole Tree from $apply, $evalAsync, and $applyAsync
Jan 6, 2014
d08cbed
Substituting The Parent Scope
teropa Nov 15, 2014
0eb7e46
Destroying Scopes
Jan 6, 2014
879ca2c
Update CONTRIBUTING.md
Foxandxss Jan 12, 2014
3862552
Update README, fix contributing url.
Foxandxss Jan 10, 2014
23d0e05
Setting Up The Infrastructure for Watching Collections
Jan 18, 2014
c9d8ed7
Detecting Non-Collection Changes
Jan 18, 2014
ee860dc
Handling NaNs in $watchCollection
teropa Mar 29, 2014
4e0d4a4
Detecting New Arrays
Jan 18, 2014
bac900f
Detecting New Or Removed Items in Arrays
Jan 18, 2014
b639724
Detecting Replaced or Reordered Items in Arrays
Jan 18, 2014
b192c26
Array-Like Objects
Jan 18, 2014
77f2b3d
Detecting New Objects
Jan 18, 2014
814cef2
Detecting New Or Replaced Attributes In Objects
Jan 18, 2014
4d4d680
Detecting Removed Attributes In Objects
Jan 18, 2014
fe2b0c8
Preventing Unnecessary Object Iteration
Jan 18, 2014
1da5f3e
Dealing with Objects that Have A length
Jan 18, 2014
57ea9e5
Handing The Old Collection Value To Listeners
teropa Mar 29, 2014
a289ff6
Events: Test Setup
Feb 1, 2014
97f9e20
Registering Event Listeners: $on
Feb 1, 2014
919f0f8
The basics if $emit and $broadcast
Feb 1, 2014
5d7b1a6
Dealing with Duplication
Feb 1, 2014
314da6b
Event Objects
Feb 1, 2014
2a28962
Additional Listener Arguments
Feb 1, 2014
9e6cfd4
Returning The Event Object
Feb 1, 2014
75edef5
Deregistering Event Listeners
Feb 1, 2014
bab4c8f
Emitting Up The Scope Hierarchy
Feb 1, 2014
a39f485
Broadcasting Down The Scope Hierarchy
Feb 1, 2014
02fc3f8
Including The Current And Target Scopes in The Event Object
Feb 1, 2014
937f098
Stopping Event Propagation
Feb 1, 2014
c847292
Preventing Default Event Behavior
Feb 1, 2014
413af69
Broadcasting Scope Removal
Feb 1, 2014
5d78013
Disabling Listeners On Destroyed Scopes
teropa Aug 16, 2015
5b2468b
Handling Event Listener Exceptions
Feb 1, 2014
22d6720
Parsing Setup
teropa Jul 14, 2015
210da9e
Parsing Integers
teropa Jul 14, 2015
66137f0
Parsing Floating Point Numbers
teropa Jul 14, 2015
99e4e49
Parsing Scientific Notation
teropa Jul 14, 2015
e6f3066
Parsing Strings
teropa Jul 14, 2015
c5d4bc9
Parsing true, false, and null
teropa Jul 15, 2015
908349c
Parsing Whitespace
teropa Jul 15, 2015
19a0dab
Parsing Arrays
teropa Jul 15, 2015
d68a0b3
Parsing Objects
teropa Jul 15, 2015
5b68ec7
Simple Attribute Lookup
teropa Jul 15, 2015
9050a91
Parsing this
teropa Jul 15, 2015
656929a
Non-Computed Attribute Lookup
teropa Jul 17, 2015
6bb32b5
Locals
teropa Jul 22, 2015
eef678a
Computed Attribute Lookup
teropa Jul 22, 2015
a8af458
Function Calls
teropa Jul 22, 2015
153f224
Method Calls
teropa Jul 22, 2015
5cd4b80
Assigning Values
teropa Jul 22, 2015
aa0e651
Ensuring Safety In Member Access
teropa Jul 22, 2015
cc0911a
Ensuring Safe Objects
teropa Jul 22, 2015
044fccb
Ensuring Safe Functions
teropa Jul 22, 2015
4f6b954
Unary Operators
teropa Jul 22, 2015
f3cb4e7
Multiplicative Operators
teropa Jul 22, 2015
20a197d
Additive Operators
teropa Jul 22, 2015
759e125
Relational And Equality Operators
teropa Jul 22, 2015
cccd278
Logical Operators AND And OR
teropa Jul 23, 2015
a65a011
The Ternary Operator
teropa Jul 23, 2015
a57dd50
Altering The Precedence Order with Parentheses
teropa Jul 23, 2015
8029d3d
Statements
teropa Jul 23, 2015
0d6bb35
Filter Registration
teropa Jul 29, 2015
516b6b1
Filter Expressions
teropa Jul 30, 2015
b3b8c3e
Filter Chain Expressions
teropa Jul 30, 2015
8524d41
Additional Filter Arguments
teropa Jul 30, 2015
c79d2b4
The Filter Filter
teropa Jul 30, 2015
7f55c09
Filtering With Predicate Functions
teropa Jul 30, 2015
3e4c8c5
Filtering With Strings
teropa Jul 30, 2015
5683488
Filtering With Other Primitives
teropa Jul 30, 2015
f0c205a
Negated Filtering With Strings
teropa Jul 30, 2015
cc9edf8
Filtering With Object Criteria
teropa Jul 30, 2015
7846dfa
Filtering With Object Wildcards
teropa Jul 30, 2015
c2904ef
Filtering With Custom Comparators
teropa Jul 30, 2015
f9a2774
Integrating Expressions to Scopes
teropa Jul 23, 2015
43cad1a
Literal And Constant Expressions
teropa Jul 23, 2015
8707a90
Optimizing Constant Expression Watching
teropa Jul 23, 2015
fb7364a
One-Time Expressions
teropa Jul 23, 2015
2e580ac
Input Tracking
teropa Jul 23, 2015
dd2a925
Stateful Filters
teropa Jul 31, 2015
9e86925
External Assignment
teropa Jul 23, 2015
d81893a
The angular Global
teropa May 18, 2014
18f2cfc
Initializing The Global Just Once
teropa May 18, 2014
b739bca
The module Method
teropa May 18, 2014
dad5497
Registering A Module
teropa May 18, 2014
a707ab1
Getting A Registered Module
teropa May 18, 2014
c818672
The Injector
teropa May 18, 2014
a71ef41
Registering A Constant
teropa May 18, 2014
5713ffd
Requiring Other Modules
teropa May 18, 2014
ad1041c
Dependency Injection
teropa May 18, 2014
80e0e14
Rejecting Non-String DI Tokens
teropa May 18, 2014
d62361d
Binding this In Injected Functions
teropa May 18, 2014
dd63313
Providing Locals to Injected Functions
teropa May 18, 2014
f61b0a7
Array-style Dependency Annotation
teropa May 18, 2014
fc7a2d0
Dependency Annotation from Function Arguments
teropa May 18, 2014
c06d1c8
Strict Mode
teropa Nov 15, 2014
3987838
Integrating Annotation with Invocation
teropa May 18, 2014
63797f1
Instantiating Objects with Dependency Injection
teropa May 24, 2014
50c95f8
The Simplest Possible Provider: An Object with A $get Method
teropa May 20, 2014
68a3ede
Injecting Dependencies to The $get Method
teropa May 21, 2014
c6f87bc
Lazy Instantiation of Dependencies
teropa May 21, 2014
47f8c6a
Making Sure Everything Is A Singleton
teropa May 22, 2014
43e392c
Circular Dependencies
teropa May 22, 2014
a845c8c
Provider Constructors
teropa May 24, 2014
8ab5f23
Two Injectors: The Provider Injector and The Instance Injector
teropa May 24, 2014
04cd196
Unshifting Constants in The Invoke Queue
teropa May 24, 2014
1189928
Injecting The $injectors
teropa May 27, 2014
9607568
Injecting $provide
teropa May 27, 2014
89d423f
Config Blocks
teropa May 28, 2014
e050535
Run Blocks
teropa May 29, 2014
69a06ea
Function Modules
teropa Jun 10, 2014
c63a147
Factories
teropa Jun 10, 2014
9733e76
Values
teropa Jun 10, 2014
b7d7a5b
Services
teropa Jun 10, 2014
728b782
Decorators
teropa Jun 11, 2014
63acae5
Integrating Scopes, Expressions, and Filters with The Injector
teropa Jun 13, 2014
005c68d
Making a Configurable Provider: Digest TTL
teropa Jun 13, 2014
fe84bc3
The $q Provider
teropa Jan 13, 2015
a5dac26
Creating Deferreds
teropa Jan 26, 2015
3753968
Accessing The Promise of A Deferred
teropa Jan 26, 2015
38ccb8c
Resolving A Deferred
teropa Jan 26, 2015
80244e8
Preventing Multiple Resolutions
teropa Jan 26, 2015
9a72c56
Ensuring that Callbacks Get Invoked
teropa Jan 26, 2015
23a50ca
Registering Multiple Promise Callbacks
teropa Jan 26, 2015
fd10d65
Rejecting Deferreds And Catching Rejections
teropa Jan 26, 2015
5b2c83e
Cleaning Up At The End: finally
teropa Jan 27, 2015
011d35e
Promise Chaining
teropa Jan 28, 2015
8312b8e
Exception Handling
teropa Feb 17, 2015
444f899
Nested Promises
teropa Feb 17, 2015
6f4897c
Chaining Handlers on finally
teropa Feb 17, 2015
4cc9a4e
Notifying Progress
teropa Feb 18, 2015
48b43a0
Immediate Rejection - $q.reject
teropa Feb 18, 2015
8a3ee7e
Immediate Fullfillment - $q.when
teropa Feb 18, 2015
52b0ecb
Working with Promise Collections - $q.all
teropa Feb 18, 2015
f23bc16
ES6 Style Promises
teropa Feb 19, 2015
0e4bea3
Promises Without $digest Integration: $$q
teropa Feb 19, 2015
52c788e
The $http Providers
teropa Mar 19, 2015
f79fe1c
Sending HTTP Requests
teropa Mar 19, 2015
e40b95b
Default Request Configuration
teropa Mar 19, 2015
0d337fc
Request Headers
teropa Mar 22, 2015
745f060
Response Headers
teropa Mar 22, 2015
9ff8ad0
Allow CORS Authorization: withCredentials
teropa Mar 22, 2015
8f56c6f
Request Transforms
teropa Mar 22, 2015
dab5b0f
Response Transforms
teropa Mar 22, 2015
e216854
JSON Serialization And Parsing
teropa Mar 23, 2015
e38c1cf
URL Parameters
teropa Mar 23, 2015
07c03d8
Shorthand Methods
teropa Mar 23, 2015
aa021d4
Interceptors
teropa Mar 23, 2015
ec13590
Promise Extensions
teropa Mar 23, 2015
eb06624
Request Timeouts
teropa Mar 23, 2015
8629d53
Pending Requests
teropa Mar 23, 2015
0de065d
Integrating $http and $applyAsync
teropa Apr 2, 2015
0b5fb75
Creating The $compile Provider
teropa Aug 2, 2014
3969838
Registering Directives
teropa Aug 2, 2014
c7cb5d1
Compiling The DOM with Element Directives
teropa Aug 2, 2014
0481fe0
Recursing to Child Elements
teropa Aug 3, 2014
0a08805
Using Prefixes with Element Directives
teropa Aug 3, 2014
7176806
Applying Directives to Attributes
teropa Aug 3, 2014
a0b4e0c
Applying Directives to Classes
teropa Aug 3, 2014
d3f3e1e
Applying Directives to Comments
teropa Aug 3, 2014
4ae1fb0
Restricting Directive Application
teropa Aug 3, 2014
467fca2
Prioritizing Directives
teropa May 23, 2015
0275906
Terminating Compilation
teropa May 23, 2015
f951e6a
Applying Directives Across Multiple Nodes
teropa Aug 3, 2014
fb95216
added MIT license to the code
teropa Aug 9, 2014
cbe736e
Passing Attributes to the compile Function
teropa Aug 12, 2014
d79b2ac
Handling Boolean Attributes
teropa Aug 12, 2014
04b05e0
Overriding attributes with ng-attr
teropa Nov 16, 2014
dff8630
Setting Attributes
teropa Aug 13, 2014
12d065c
Setting Boolean Properties
teropa Aug 13, 2014
a85706c
Denormalizing Attribute Names for The DOM
teropa Aug 14, 2014
81f75f0
Observing Attributes
teropa Aug 15, 2014
1ce27e3
Adding Class Directives As Attributes
teropa Aug 16, 2014
a8911a8
Adding Comment Directives As Attributes
teropa Aug 16, 2014
b557c2b
Manipulating Classes
teropa Aug 16, 2014
a915c18
ignore .DS_Store
teropa Oct 12, 2014
e33f86e
The Public Link Function
teropa Dec 9, 2014
44e9662
Directive Link Functions
teropa Dec 9, 2014
0164283
Plain Directive Link Functions
teropa Dec 9, 2014
185fa7b
Linking Child Nodes
teropa Dec 10, 2014
a3bda61
Pre- and Post-Linking
teropa Dec 10, 2014
df7b6d0
Keeping The Node List Stable for Linking
teropa Dec 11, 2014
f3150cf
Linking Directives Across Multiple Nodes
teropa Dec 11, 2014
60fea3e
Linking And Scope Inheritance
teropa Dec 15, 2014
d02a7b4
Isolate Scopes
teropa Dec 16, 2014
dab80b4
Isolate Attribute Bindings
teropa Dec 17, 2014
d5f74e4
Two-Way Data Binding
teropa Dec 22, 2014
747e988
Expression Binding
teropa Dec 22, 2014
1b81ad9
The $controller provider
teropa Dec 27, 2014
0b2beda
Controller Instantiation
teropa Dec 27, 2014
939fae4
Controller Registration
teropa Dec 27, 2014
6bf6295
Global Controller Lookup
teropa Dec 27, 2014
d70f15d
Locals in Directive Controllers
teropa Dec 27, 2014
1fefda9
Attaching Directive Controllers on The Scope
teropa Dec 27, 2014
7d0ac58
Controllers on Isolate Scope Directives
teropa Dec 27, 2014
de6c800
Requiring Controllers
teropa Dec 27, 2014
0c59714
Requiring Multiple Controllers
teropa Dec 27, 2014
60533dd
Self-Requiring Directives
teropa Dec 27, 2014
b296b21
Requiring Controllers in Multi-Element Directives
teropa Dec 27, 2014
ec36b92
Requiring Controllers from Parent Elements
teropa Dec 27, 2014
1260138
Optionally Requiring Controllers
teropa Dec 27, 2014
d4bec44
The ngController Directive
teropa Dec 27, 2014
394037b
Attaching Controllers on The Scope
teropa Dec 27, 2014
5e203fd
Basic Templating
teropa Apr 11, 2015
f9f2dd2
Disallowing More Than One Template Directive Per Element
teropa Apr 11, 2015
65fd6f6
Template Functions
teropa Apr 11, 2015
b973d5d
Isolate Scope Directives with Templates
teropa Apr 11, 2015
63ec560
Asynchronous Templates
teropa Apr 11, 2015
e76f7e3
Template URL Functions
teropa Apr 11, 2015
260d5f0
Linking Asynchronous Directives
teropa Apr 11, 2015
86b5fb3
Linking Directives that Were Compiled Earlier
teropa Apr 11, 2015
5c07f70
Preserving The Isolate Scope Directive
teropa Apr 11, 2015
aee7d15
Preserving Controller Directives
teropa Apr 27, 2015
e6bc7b5
Basic Transclusion
teropa May 31, 2015
fdc8d9b
Transclusion and Scopes
teropa Jun 1, 2015
0f875c2
Transclusion from Descendant Nodes
teropa Jun 1, 2015
b467a80
Transclusion in Controllers
teropa Jun 1, 2015
072b1a8
The Clone Attach Function
teropa Jun 3, 2015
b1442b4
Transclusion with Template URLs
teropa Jun 4, 2015
d7bda9c
Transclusion with Multi-Element Directives
teropa Jun 4, 2015
2a8e1b7
The ngTransclude Directive
teropa Jun 4, 2015
df350a6
Full Element Transclusion
teropa Jun 5, 2015
44c6bad
Requiring Controllers from Transcluded Directives
teropa Jun 5, 2015
8fc7890
The $interpolate Service
teropa Jun 10, 2015
4169ce8
Interpolating Strings
teropa Jun 11, 2015
e2646aa
Value Stringification
teropa Jun 11, 2015
59c35f7
Supporting Escaped Interpolation Symbols
teropa Jun 11, 2015
bcbee5c
Skipping Interpolation When There Are No Expressions
teropa Jun 11, 2015
bfa4e08
Text Node Interpolation
teropa Jun 11, 2015
d199780
Attribute Interpolation
teropa Jun 11, 2015
0f5f2ec
Optimizing Interpolation Watches With A Watch Delegate
teropa Jun 11, 2015
80bbdea
Making Interpolation Symbols Configurable
teropa Jun 15, 2015
71876a4
The ngClick Directive
teropa Nov 4, 2015
0a877ed
Bootstrapping Angular Applications Manually
teropa Nov 4, 2015
9198af9
Bootstrapping Angular Applications Automatically
teropa Nov 4, 2015
13690c2
Building The Production Bundle
teropa Nov 4, 2015
4cb49bf
Example App
teropa Nov 5, 2015
4ff5094
add missing test
Foxandxss Apr 2, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules/
.DS_Store
myangular.js
myangular.min.js
10 changes: 9 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"browser": true,
"browserify": true,
"devel": true
"devel": true,
"globals": {
"jasmine": false,
"describe": false,
"it": false,
"expect": false,
"beforeEach": false,
"afterEach": false
}
}
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ If you find a bug, typo, or some other kind of issue in the book content or in t
it if you reported it to the [Issues](https://github.com/teropa/build-your-own-angularjs/issues) section of this
repository.

When reporting an issue, please use the following conventions:
When reporting an issue, please use the following convention:

* Prefix the issue title with the corresponding page number (e.g. "P45")
* Assign a chapter label to the issue (one of "chapter1", "chapter2", etc.)

Your feedback is much appreciated!
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2010-2014 Tero Parviainen
Based on AngularJS, Copyright (c) 2010-2014 Google, Inc. http://angularjs.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ There is also a tag for each chapter, pointing to the state of the codebase at t

The [Issues](https://github.com/teropa/build-your-own-angularjs/issues) setion of this repository contains the book's errata.

If you find bugs, typos, mistakes, or other issues that should be improved, I would love to hear about it. See [CONTRIBUTING.md](CONTRIBUTING.MD).
If you find bugs, typos, mistakes, or other issues that should be improved, I would love to hear about it. See [CONTRIBUTING.md](CONTRIBUTING.md).

10 changes: 10 additions & 0 deletions example-app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
angular.module('myExampleApp', [])
.controller('ExampleController', function() {
this.counter = 1;
this.increment = function() {
this.counter++;
};
this.decrement = function() {
this.counter--;
};
});
14 changes: 14 additions & 0 deletions example-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body ng-app="myExampleApp">
<div ng-controller="ExampleController as ctrl">
{{ctrl.counter}}
<button ng-click="ctrl.increment()">+</button>
<button ng-click="ctrl.decrement()">-</button>
</div>
<script src="../myangular.js"></script>
<script src="app.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = function(config) {
config.set({
frameworks: ['browserify', 'jasmine'],
files: [
'src/**/*.js',
'test/**/*_spec.js'
],
preprocessors: {
'test/**/*.js': ['jshint', 'browserify'],
'src/**/*.js': ['jshint', 'browserify']
},
browsers: ['PhantomJS'],
browserify: {
debug: true,
bundleDelay: 2000 // Fixes "reload" error messages, YMMV!
}
})
}
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,26 @@
"name": "my-own-angularjs",
"version": "0.1.0",
"devDependencies": {
"jshint": "^2.8.0"
"browserify": "^12.0.1",
"jasmine-core": "^2.3.4",
"jshint": "^2.8.0",
"karma": "^0.13.15",
"karma-browserify": "^4.4.0",
"karma-jasmine": "^0.3.6",
"karma-jshint-preprocessor": "0.0.6",
"karma-phantomjs-launcher": "^0.2.1",
"phantomjs": "^1.9.18",
"sinon": "^1.17.2",
"uglifyjs": "^2.4.10"
},
"dependencies": {
"jquery": "^2.1.4",
"lodash": "^3.10.1"
},
"scripts": {
"lint": "jshint src"
"lint": "jshint src test",
"test": "karma start",
"build": "browserify src/bootstrap.js > myangular.js",
"build:minified": "browserify src/bootstrap.js | uglifyjs -mc > myangular.min.js"
}
}
26 changes: 26 additions & 0 deletions src/angular_public.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

var setupModuleLoader = require('./loader');

function publishExternalAPI() {
setupModuleLoader(window);

var ngModule = window.angular.module('ng', []);
ngModule.provider('$filter', require('./filter'));
ngModule.provider('$parse', require('./parse'));
ngModule.provider('$rootScope', require('./scope'));
ngModule.provider('$q', require('./q').$QProvider);
ngModule.provider('$$q', require('./q').$$QProvider);
ngModule.provider('$httpBackend', require('./http_backend'));
ngModule.provider('$http', require('./http').$HttpProvider);
ngModule.provider('$httpParamSerializer', require('./http').$HttpParamSerializerProvider);
ngModule.provider('$httpParamSerializerJQLike', require('./http').$HttpParamSerializerJQLikeProvider);
ngModule.provider('$compile', require('./compile'));
ngModule.provider('$controller', require('./controller'));
ngModule.provider('$interpolate', require('./interpolate'));
ngModule.directive('ngController', require('./directives/ng_controller'));
ngModule.directive('ngTransclude', require('./directives/ng_transclude'));
ngModule.directive('ngClick', require('./directives/ng_click'));
}

module.exports = publishExternalAPI;
52 changes: 52 additions & 0 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';

var $ = require('jquery');
var _ = require('lodash');
var publishExternalAPI = require('./angular_public');
var createInjector = require('./injector');

publishExternalAPI();

window.angular.bootstrap = function(element, modules, config) {
var $element = $(element);
modules = modules || [];
config = config || {};
modules.unshift(['$provide', function($provide) {
$provide.value('$rootElement', $element);
}]);
modules.unshift('ng');
var injector = createInjector(modules, config.strictDi);
$element.data('$injector', injector);
injector.invoke(['$compile', '$rootScope', function($compile, $rootScope) {
$rootScope.$apply(function() {
$compile($element)($rootScope);
});
}]);
return injector;
};

var ngAttrPrefixes = ['ng-', 'data-ng-', 'ng:', 'x-ng-'];
$(document).ready(function() {
var foundAppElement, foundModule, config = {};
_.forEach(ngAttrPrefixes, function(prefix) {
var attrName = prefix + 'app';
var selector = '[' + attrName.replace(':', '\\:') + ']';
var element;
if (!foundAppElement &&
(element = document.querySelector(selector))) {
foundAppElement = element;
foundModule = element.getAttribute(attrName);
}
});
if (foundAppElement) {
config.strictDi = _.any(ngAttrPrefixes, function(prefix) {
var attrName = prefix + 'strict-di';
return foundAppElement.hasAttribute(attrName);
});
window.angular.bootstrap(
foundAppElement,
foundModule ? [foundModule] : [],
config
);
}
});
Loading