Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5599b55

Browse files
committed
refactor($route): pull $route and friends into angular-route.js
$route, $routeParams and ngView have been pulled from core angular.js to angular-route.js/ngRoute module. This is was done to in order keep the core focused on most commonly used functionality and allow community routers to be freely used instead of $route service. There is no need to panic, angular-route will keep on being supported by the angular team. Note: I'm intentionally not fixing tutorial links. Tutorial will need bigger changes and those should be done when we update tutorial to 1.2. BREAKING CHANGE: applications that use $route will now need to load angular-route.js file and define dependency on ngRoute module. Before: ``` ... <script src="angular.js"></script> ... var myApp = angular.module('myApp', ['someOtherModule']); ... ``` After: ``` ... <script src="angular.js"></script> <script src="angular-route.js"></script> ... var myApp = angular.module('myApp', ['ngRoute', 'someOtherModule']); ... ``` Closes #2804
1 parent 7a5cfb5 commit 5599b55

25 files changed

+157
-123
lines changed

Gruntfile.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,22 @@ module.exports = function(grunt) {
104104
src: util.wrap([
105105
'src/ngSanitize/sanitize.js',
106106
'src/ngSanitize/directive/ngBindHtml.js',
107-
'src/ngSanitize/filter/linky.js',
107+
'src/ngSanitize/filter/linky.js'
108108
], 'module')
109109
},
110110
resource: {
111111
dest: 'build/angular-resource.js',
112112
src: util.wrap(['src/ngResource/resource.js'], 'module')
113113
},
114+
route: {
115+
dest: 'build/angular-route.js',
116+
src: util.wrap([
117+
'src/ngRoute/routeUtils.js',
118+
'src/ngRoute/route.js',
119+
'src/ngRoute/routeParams.js',
120+
'src/ngRoute/directive/ngView.js'
121+
], 'module')
122+
},
114123
cookies: {
115124
dest: 'build/angular-cookies.js',
116125
src: util.wrap(['src/ngCookies/cookies.js'], 'module')
@@ -136,6 +145,7 @@ module.exports = function(grunt) {
136145
loader: 'build/angular-loader.js',
137146
mobile: 'build/angular-mobile.js',
138147
resource: 'build/angular-resource.js',
148+
route: 'build/angular-route.js',
139149
sanitize: 'build/angular-sanitize.js',
140150
bootstrap: 'build/docs/components/angular-bootstrap.js',
141151
bootstrapPrettify: 'build/docs/components/angular-bootstrap-prettify.js',

angularFiles.js

+12-26
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ angularFiles = {
2323
'src/ng/log.js',
2424
'src/ng/parse.js',
2525
'src/ng/q.js',
26-
'src/ng/route.js',
27-
'src/ng/routeParams.js',
2826
'src/ng/rootScope.js',
2927
'src/ng/sniffer.js',
3028
'src/ng/window.js',
@@ -60,7 +58,6 @@ angularFiles = {
6058
'src/ng/directive/ngStyle.js',
6159
'src/ng/directive/ngSwitch.js',
6260
'src/ng/directive/ngTransclude.js',
63-
'src/ng/directive/ngView.js',
6461
'src/ng/directive/script.js',
6562
'src/ng/directive/select.js',
6663
'src/ng/directive/style.js'
@@ -69,6 +66,10 @@ angularFiles = {
6966
'angularSrcModules': [
7067
'src/ngCookies/cookies.js',
7168
'src/ngResource/resource.js',
69+
'src/ngRoute/routeUtils.js',
70+
'src/ngRoute/route.js',
71+
'src/ngRoute/routeParams.js',
72+
'src/ngRoute/directive/ngView.js',
7273
'src/ngSanitize/sanitize.js',
7374
'src/ngSanitize/directive/ngBindHtml.js',
7475
'src/ngSanitize/filter/linky.js',
@@ -106,19 +107,14 @@ angularFiles = {
106107
'test/ngScenario/jstd-scenario-adapter/*.js',
107108
'test/*.js',
108109
'test/auto/*.js',
109-
'test/ng/*.js',
110-
'test/ng/directive/*.js',
111-
'test/ng/filter/*.js',
110+
'test/ng/**/*.js',
112111
'test/ngCookies/*.js',
113112
'test/ngResource/*.js',
114-
'test/ngSanitize/*.js',
115-
'test/ngSanitize/directive/*.js',
116-
'test/ngSanitize/filter/*.js',
113+
'test/ngRoute/**/*.js',
114+
'test/ngSanitize/**/*.js',
117115
'test/ngMock/*.js',
118-
'test/ngMobile/*.js',
119-
'test/ngMobile/directive/*.js',
120-
'docs/component-spec/bootstrap/*.js',
121-
'docs/component-spec/*.js'
116+
'test/ngMobile/**/*.js',
117+
'docs/component-spec/**/*.js'
122118
],
123119

124120
'jstd': [
@@ -153,25 +149,15 @@ angularFiles = {
153149
'lib/jasmine/jasmine.js',
154150
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
155151
'build/angular.js',
156-
'src/ngMock/angular-mocks.js',
157-
'src/ngCookies/cookies.js',
158-
'src/ngResource/resource.js',
159-
'src/ngMobile/mobile.js',
160-
'src/ngMobile/swipe.js',
161-
'src/ngMobile/directive/ngClick.js',
162-
'src/ngMobile/directive/ngSwipe.js',
163-
'src/ngSanitize/sanitize.js',
164-
'src/ngSanitize/directive/ngBindHtml.js',
165-
'src/ngSanitize/filter/linky.js',
152+
'@angularSrcModules',
166153
'src/ngScenario/browserTrigger.js',
167154
'test/matchers.js',
168155
'test/testabilityPatch.js',
169156
'test/ngMock/*.js',
170157
'test/ngCookies/*.js',
158+
'test/ngRoute/**/*.js',
171159
'test/ngResource/*.js',
172-
'test/ngSanitize/*.js',
173-
'test/ngSanitize/directive/*.js',
174-
'test/ngSanitize/filter/*.js',
160+
'test/ngSanitize/**/*.js',
175161
'test/ngMobile/**/*.js'
176162
],
177163

docs/components/bootstrap/bootstrap-prettify.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var service = { value: {} };
66
var DEPENDENCIES = {
77
'angular.js': 'http://code.angularjs.org/' + angular.version.full + '/angular.min.js',
88
'angular-resource.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-resource.min.js',
9+
'angular-route.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-route.min.js',
910
'angular-sanitize.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-sanitize.min.js',
1011
'angular-cookies.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-cookies.min.js'
1112
};

docs/content/cookbook/deeplinking.ngdoc

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ In this example we have a simple app which consist of two screens:
3030
* Welcome: url `welcome` Show the user contact information.
3131
* Settings: url `settings` Show an edit screen for user contact information.
3232

33-
<example module="deepLinking" deps="angular-sanitize.js">
33+
<example module="deepLinking" deps="angular-route.js, angular-sanitize.js">
3434
<file name="script.js">
35-
angular.module('deepLinking', ['ngSanitize'])
35+
angular.module('deepLinking', ['ngRoute', 'ngSanitize'])
3636
.config(function($routeProvider) {
3737
$routeProvider.
3838
when("/welcome", {templateUrl:'welcome.html', controller:WelcomeCntl}).
@@ -141,11 +141,11 @@ In this example we have a simple app which consist of two screens:
141141
# Things to notice
142142

143143
* Routes are defined in the `AppCntl` class. The initialization of the controller causes the
144-
initialization of the {@link api/ng.$route $route} service with the proper URL
144+
initialization of the {@link api/ngRoute.$route $route} service with the proper URL
145145
routes.
146-
* The {@link api/ng.$route $route} service then watches the URL and instantiates the
146+
* The {@link api/ngRoute.$route $route} service then watches the URL and instantiates the
147147
appropriate controller when the URL changes.
148-
* The {@link api/ng.directive:ngView ngView} widget loads the
148+
* The {@link api/ngRoute.directive:ngView ngView} widget loads the
149149
view when the URL changes. It also sets the view scope to the newly instantiated controller.
150150
* Changing the URL is sufficient to change the controller and view. It makes no difference whether
151151
the URL is changed programatically or by the user.

docs/content/guide/dev_guide.mvc.understanding_controller.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ instances).
8484
# Associating Controllers with Angular Scope Objects
8585

8686
You can associate controllers with scope objects implicitly via the {@link api/ng.directive:ngController ngController
87-
directive} or {@link api/ng.$route $route service}.
87+
directive} or {@link api/ngRoute.$route $route service}.
8888

8989

9090
## Controller Constructor and Methods Example

docs/content/guide/dev_guide.mvc.understanding_view.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ the DOM based on information in the template, controller and model.
1010
In the Angular implementation of MVC, the view has knowledge of both the model and the controller.
1111
The view knows about the model where two-way data-binding occurs. The view has knowledge of the
1212
controller through Angular directives, such as {@link api/ng.directive:ngController
13-
ngController} and {@link api/ng.directive:ngView ngView}, and through bindings of this form:
13+
ngController} and {@link api/ngRoute.directive:ngView ngView}, and through bindings of this form:
1414
`{{someControllerFunction()}}`. In these ways, the view can call functions in an associated
1515
controller function.
1616

docs/content/guide/dev_guide.services.managing_dependencies.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Things to notice in this example:
9191
* The `batchLog` service depends on the built-in {@link api/ng.$timeout $timeout} and
9292
{@link api/ng.$log $log} services, and allows messages to be logged into the
9393
`console.log` in batches.
94-
* The `routeTemplateMonitor` service depends on the built-in {@link api/ng.$route
94+
* The `routeTemplateMonitor` service depends on the built-in {@link api/ngRoute.$route
9595
$route} service as well as our custom `batchLog` service.
9696
* Both of our services use the factory function signature and array notation for inject annotations
9797
to declare their dependencies. It is important that the order of the string identifiers in the array

docs/content/guide/dev_guide.templates.ngdoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ with {@link expression expressions}:
4141
In a simple single-page app, the template consists of HTML, CSS, and angular directives contained
4242
in just one HTML file (usually `index.html`). In a more complex app, you can display multiple views
4343
within one main page using "partials", which are segments of template located in separate HTML
44-
files. You "include" the partials in the main page using the {@link api/ng.$route
45-
$route} service in conjunction with the {@link api/ng.directive:ngView ngView} directive. An
44+
files. You "include" the partials in the main page using the {@link api/ngRoute.$route
45+
$route} service in conjunction with the {@link api/ngRoute.directive:ngView ngView} directive. An
4646
example of this technique is shown in the {@link tutorial/ angular tutorial}, in steps seven and
4747
eight.
4848

docs/content/guide/directive.ngdoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ In this example we will build a directive that displays the current time.
250250

251251
# Writing directives (long version)
252252

253-
There are different ways to declare a directive. The difference resides in the return
253+
There are different ways to declare a directive. The difference resides in the return
254254
value of the factory function. You can either return a Directive Definition Object
255255
(see below) that defines the directive properties, or just the postLink function
256256
of such an object (all other properties will have the default values).
@@ -284,7 +284,7 @@ Here's an example directive declared with a Directive Definition Object:
284284

285285
In most cases you will not need such fine control and so the above can be simplified. You can still
286286
return a Directive Definition Object, but only setting the 'compile' function property of the Object,
287-
and rely on the default values for other properties.
287+
and rely on the default values for other properties.
288288

289289
Therefore the above can be simplified as:
290290

@@ -462,7 +462,7 @@ The compile function deals with transforming the template DOM. Since most direct
462462
template transformation, it is not used often. Examples that require compile functions are
463463
directives that transform template DOM, such as {@link
464464
api/ng.directive:ngRepeat ngRepeat}, or load the contents
465-
asynchronously, such as {@link api/ng.directive:ngView ngView}. The
465+
asynchronously, such as {@link api/ngRoute.directive:ngView ngView}. The
466466
compile function takes the following arguments.
467467

468468
* `tElement` - template element - The element where the directive has been declared. It is

docs/src/templates/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
if (jQuery) addTag('script', {src: debug ? 'js/jquery.js' : 'js/jquery.min.js'});
3939
addTag('script', {src: path('angular.js')}, sync);
4040
addTag('script', {src: path('angular-resource.js') }, sync);
41+
addTag('script', {src: path('angular-route.js') }, sync);
4142
addTag('script', {src: path('angular-cookies.js') }, sync);
4243
addTag('script', {src: path('angular-sanitize.js') }, sync);
4344
addTag('script', {src: path('angular-mobile.js') }, sync);

docs/src/templates/js/docs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
679679
};
680680

681681

682-
angular.module('docsApp', ['ngResource', 'ngCookies', 'ngSanitize', 'bootstrap', 'bootstrapPrettify']).
682+
angular.module('docsApp', ['ngResource', 'ngRoute', 'ngCookies', 'ngSanitize', 'bootstrap', 'bootstrapPrettify']).
683683
config(function($locationProvider) {
684684
$locationProvider.html5Mode(true).hashPrefix('!');
685685
}).

src/AngularPublic.js

-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ function publishExternalAPI(angular){
9595
ngSwitchWhen: ngSwitchWhenDirective,
9696
ngSwitchDefault: ngSwitchDefaultDirective,
9797
ngOptions: ngOptionsDirective,
98-
ngView: ngViewDirective,
9998
ngTransclude: ngTranscludeDirective,
10099
ngModel: ngModelDirective,
101100
ngList: ngListDirective,
@@ -122,8 +121,6 @@ function publishExternalAPI(angular){
122121
$location: $LocationProvider,
123122
$log: $LogProvider,
124123
$parse: $ParseProvider,
125-
$route: $RouteProvider,
126-
$routeParams: $RouteParamsProvider,
127124
$rootScope: $RootScopeProvider,
128125
$q: $QProvider,
129126
$sniffer: $SnifferProvider,

src/ng/animator.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* | Directive | Supported Animations |
1919
* |========================================================== |====================================================|
2020
* | {@link ng.directive:ngRepeat#animations ngRepeat} | enter, leave and move |
21-
* | {@link ng.directive:ngView#animations ngView} | enter and leave |
21+
* | {@link ngRoute.directive:ngView#animations ngView} | enter and leave |
2222
* | {@link ng.directive:ngInclude#animations ngInclude} | enter and leave |
2323
* | {@link ng.directive:ngSwitch#animations ngSwitch} | enter and leave |
2424
* | {@link ng.directive:ngIf#animations ngIf} | enter and leave |
@@ -183,7 +183,7 @@ var $AnimatorProvider = function() {
183183
*/
184184
var AnimatorService = function(scope, attrs) {
185185
var animator = {};
186-
186+
187187
/**
188188
* @ngdoc function
189189
* @name ng.animator#enter
@@ -198,7 +198,7 @@ var $AnimatorProvider = function() {
198198
* @param {jQuery/jqLite element} after the sibling element (which is the previous element) of the element that will be the focus of the enter animation
199199
*/
200200
animator.enter = animateActionFactory('enter', insert, noop);
201-
201+
202202
/**
203203
* @ngdoc function
204204
* @name ng.animator#leave
@@ -212,7 +212,7 @@ var $AnimatorProvider = function() {
212212
* @param {jQuery/jqLite element} parent the parent element of the element that will be the focus of the leave animation
213213
*/
214214
animator.leave = animateActionFactory('leave', noop, remove);
215-
215+
216216
/**
217217
* @ngdoc function
218218
* @name ng.animator#move
@@ -228,7 +228,7 @@ var $AnimatorProvider = function() {
228228
* @param {jQuery/jqLite element} after the sibling element (which is the previous element) of the element that will be the focus of the move animation
229229
*/
230230
animator.move = animateActionFactory('move', move, noop);
231-
231+
232232
/**
233233
* @ngdoc function
234234
* @name ng.animator#show
@@ -241,7 +241,7 @@ var $AnimatorProvider = function() {
241241
* @param {jQuery/jqLite element} element the element that will be rendered visible or hidden
242242
*/
243243
animator.show = animateActionFactory('show', show, noop);
244-
244+
245245
/**
246246
* @ngdoc function
247247
* @name ng.animator#hide
@@ -262,14 +262,14 @@ var $AnimatorProvider = function() {
262262
* @description
263263
* Triggers a custom animation event to be executed on the given element
264264
*
265-
* @param {string} event the name of the custom event
265+
* @param {string} event the name of the custom event
266266
* @param {jQuery/jqLite element} element the element that will be animated
267267
*/
268268
animator.animate = function(event, element) {
269269
animateActionFactory(event, noop, noop)(element);
270270
}
271271
return animator;
272-
272+
273273
function animateActionFactory(type, beforeFn, afterFn) {
274274
return function(element, parent, after) {
275275
var ngAnimateValue = scope.$eval(attrs.ngAnimate);
@@ -329,18 +329,18 @@ var $AnimatorProvider = function() {
329329
polyfillStart(element, done, memento);
330330
} else if (isFunction($window.getComputedStyle)) {
331331
//one day all browsers will have these properties
332-
var w3cAnimationProp = 'animation';
332+
var w3cAnimationProp = 'animation';
333333
var w3cTransitionProp = 'transition';
334334

335-
//but some still use vendor-prefixed styles
335+
//but some still use vendor-prefixed styles
336336
var vendorAnimationProp = $sniffer.vendorPrefix + 'Animation';
337337
var vendorTransitionProp = $sniffer.vendorPrefix + 'Transition';
338338

339339
var durationKey = 'Duration',
340340
delayKey = 'Delay',
341341
animationIterationCountKey = 'IterationCount',
342342
duration = 0;
343-
343+
344344
//we want all the styles defined before and after
345345
var ELEMENT_NODE = 1;
346346
forEach(element, function(element) {
@@ -387,15 +387,15 @@ var $AnimatorProvider = function() {
387387
}
388388
};
389389
}
390-
390+
391391
function show(element) {
392392
element.css('display', '');
393393
}
394-
394+
395395
function hide(element) {
396396
element.css('display', 'none');
397397
}
398-
398+
399399
function insert(element, parent, after) {
400400
var afterNode = after && after[after.length - 1];
401401
var parentNode = parent && parent[0] || afterNode && afterNode.parentNode;
@@ -408,11 +408,11 @@ var $AnimatorProvider = function() {
408408
}
409409
});
410410
}
411-
411+
412412
function remove(element) {
413413
element.remove();
414414
}
415-
415+
416416
function move(element, parent, after) {
417417
// Do not remove element before insert. Removing will cause data associated with the
418418
// element to be dropped. Insert will implicitly do the remove.

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function $CompileProvider($provide) {
172172
*/
173173
this.directive = function registerDirective(name, directiveFactory) {
174174
if (isString(name)) {
175-
assertArg(directiveFactory, 'directive');
175+
assertArg(directiveFactory, 'directiveFactory');
176176
if (!hasDirectives.hasOwnProperty(name)) {
177177
hasDirectives[name] = [];
178178
$provide.factory(name + Suffix, ['$injector', '$exceptionHandler',

src/ng/directive/ngController.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* * Controller — The `ngController` directive specifies a Controller class; the class has
1616
* methods that typically express the business logic behind the application.
1717
*
18-
* Note that an alternative way to define controllers is via the {@link ng.$route $route} service.
18+
* Note that an alternative way to define controllers is via the {@link ngRoute.$route $route} service.
1919
*
2020
* @element ANY
2121
* @scope

0 commit comments

Comments
 (0)