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

Commit

Permalink
refactor($route): pull $route and friends into angular-route.js
Browse files Browse the repository at this point in the history
$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
  • Loading branch information
IgorMinar committed Jun 7, 2013
1 parent 7a5cfb5 commit 5599b55
Show file tree
Hide file tree
Showing 25 changed files with 157 additions and 123 deletions.
12 changes: 11 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,22 @@ module.exports = function(grunt) {
src: util.wrap([
'src/ngSanitize/sanitize.js',
'src/ngSanitize/directive/ngBindHtml.js',
'src/ngSanitize/filter/linky.js',
'src/ngSanitize/filter/linky.js'
], 'module')
},
resource: {
dest: 'build/angular-resource.js',
src: util.wrap(['src/ngResource/resource.js'], 'module')
},
route: {
dest: 'build/angular-route.js',
src: util.wrap([
'src/ngRoute/routeUtils.js',
'src/ngRoute/route.js',
'src/ngRoute/routeParams.js',
'src/ngRoute/directive/ngView.js'
], 'module')
},
cookies: {
dest: 'build/angular-cookies.js',
src: util.wrap(['src/ngCookies/cookies.js'], 'module')
Expand All @@ -136,6 +145,7 @@ module.exports = function(grunt) {
loader: 'build/angular-loader.js',
mobile: 'build/angular-mobile.js',
resource: 'build/angular-resource.js',
route: 'build/angular-route.js',
sanitize: 'build/angular-sanitize.js',
bootstrap: 'build/docs/components/angular-bootstrap.js',
bootstrapPrettify: 'build/docs/components/angular-bootstrap-prettify.js',
Expand Down
38 changes: 12 additions & 26 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ angularFiles = {
'src/ng/log.js',
'src/ng/parse.js',
'src/ng/q.js',
'src/ng/route.js',
'src/ng/routeParams.js',
'src/ng/rootScope.js',
'src/ng/sniffer.js',
'src/ng/window.js',
Expand Down Expand Up @@ -60,7 +58,6 @@ angularFiles = {
'src/ng/directive/ngStyle.js',
'src/ng/directive/ngSwitch.js',
'src/ng/directive/ngTransclude.js',
'src/ng/directive/ngView.js',
'src/ng/directive/script.js',
'src/ng/directive/select.js',
'src/ng/directive/style.js'
Expand All @@ -69,6 +66,10 @@ angularFiles = {
'angularSrcModules': [
'src/ngCookies/cookies.js',
'src/ngResource/resource.js',
'src/ngRoute/routeUtils.js',
'src/ngRoute/route.js',
'src/ngRoute/routeParams.js',
'src/ngRoute/directive/ngView.js',
'src/ngSanitize/sanitize.js',
'src/ngSanitize/directive/ngBindHtml.js',
'src/ngSanitize/filter/linky.js',
Expand Down Expand Up @@ -106,19 +107,14 @@ angularFiles = {
'test/ngScenario/jstd-scenario-adapter/*.js',
'test/*.js',
'test/auto/*.js',
'test/ng/*.js',
'test/ng/directive/*.js',
'test/ng/filter/*.js',
'test/ng/**/*.js',
'test/ngCookies/*.js',
'test/ngResource/*.js',
'test/ngSanitize/*.js',
'test/ngSanitize/directive/*.js',
'test/ngSanitize/filter/*.js',
'test/ngRoute/**/*.js',
'test/ngSanitize/**/*.js',
'test/ngMock/*.js',
'test/ngMobile/*.js',
'test/ngMobile/directive/*.js',
'docs/component-spec/bootstrap/*.js',
'docs/component-spec/*.js'
'test/ngMobile/**/*.js',
'docs/component-spec/**/*.js'
],

'jstd': [
Expand Down Expand Up @@ -153,25 +149,15 @@ angularFiles = {
'lib/jasmine/jasmine.js',
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
'build/angular.js',
'src/ngMock/angular-mocks.js',
'src/ngCookies/cookies.js',
'src/ngResource/resource.js',
'src/ngMobile/mobile.js',
'src/ngMobile/swipe.js',
'src/ngMobile/directive/ngClick.js',
'src/ngMobile/directive/ngSwipe.js',
'src/ngSanitize/sanitize.js',
'src/ngSanitize/directive/ngBindHtml.js',
'src/ngSanitize/filter/linky.js',
'@angularSrcModules',
'src/ngScenario/browserTrigger.js',
'test/matchers.js',
'test/testabilityPatch.js',
'test/ngMock/*.js',
'test/ngCookies/*.js',
'test/ngRoute/**/*.js',
'test/ngResource/*.js',
'test/ngSanitize/*.js',
'test/ngSanitize/directive/*.js',
'test/ngSanitize/filter/*.js',
'test/ngSanitize/**/*.js',
'test/ngMobile/**/*.js'
],

Expand Down
1 change: 1 addition & 0 deletions docs/components/bootstrap/bootstrap-prettify.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var service = { value: {} };
var DEPENDENCIES = {
'angular.js': 'http://code.angularjs.org/' + angular.version.full + '/angular.min.js',
'angular-resource.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-resource.min.js',
'angular-route.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-route.min.js',
'angular-sanitize.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-sanitize.min.js',
'angular-cookies.js': 'http://code.angularjs.org/' + angular.version.full + '/angular-cookies.min.js'
};
Expand Down
10 changes: 5 additions & 5 deletions docs/content/cookbook/deeplinking.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ In this example we have a simple app which consist of two screens:
* Welcome: url `welcome` Show the user contact information.
* Settings: url `settings` Show an edit screen for user contact information.

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

* Routes are defined in the `AppCntl` class. The initialization of the controller causes the
initialization of the {@link api/ng.$route $route} service with the proper URL
initialization of the {@link api/ngRoute.$route $route} service with the proper URL
routes.
* The {@link api/ng.$route $route} service then watches the URL and instantiates the
* The {@link api/ngRoute.$route $route} service then watches the URL and instantiates the
appropriate controller when the URL changes.
* The {@link api/ng.directive:ngView ngView} widget loads the
* The {@link api/ngRoute.directive:ngView ngView} widget loads the
view when the URL changes. It also sets the view scope to the newly instantiated controller.
* Changing the URL is sufficient to change the controller and view. It makes no difference whether
the URL is changed programatically or by the user.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ instances).
# Associating Controllers with Angular Scope Objects

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


## Controller Constructor and Methods Example
Expand Down
2 changes: 1 addition & 1 deletion docs/content/guide/dev_guide.mvc.understanding_view.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ the DOM based on information in the template, controller and model.
In the Angular implementation of MVC, the view has knowledge of both the model and the controller.
The view knows about the model where two-way data-binding occurs. The view has knowledge of the
controller through Angular directives, such as {@link api/ng.directive:ngController
ngController} and {@link api/ng.directive:ngView ngView}, and through bindings of this form:
ngController} and {@link api/ngRoute.directive:ngView ngView}, and through bindings of this form:
`{{someControllerFunction()}}`. In these ways, the view can call functions in an associated
controller function.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Things to notice in this example:
* The `batchLog` service depends on the built-in {@link api/ng.$timeout $timeout} and
{@link api/ng.$log $log} services, and allows messages to be logged into the
`console.log` in batches.
* The `routeTemplateMonitor` service depends on the built-in {@link api/ng.$route
* The `routeTemplateMonitor` service depends on the built-in {@link api/ngRoute.$route
$route} service as well as our custom `batchLog` service.
* Both of our services use the factory function signature and array notation for inject annotations
to declare their dependencies. It is important that the order of the string identifiers in the array
Expand Down
4 changes: 2 additions & 2 deletions docs/content/guide/dev_guide.templates.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ with {@link expression expressions}:
In a simple single-page app, the template consists of HTML, CSS, and angular directives contained
in just one HTML file (usually `index.html`). In a more complex app, you can display multiple views
within one main page using "partials", which are segments of template located in separate HTML
files. You "include" the partials in the main page using the {@link api/ng.$route
$route} service in conjunction with the {@link api/ng.directive:ngView ngView} directive. An
files. You "include" the partials in the main page using the {@link api/ngRoute.$route
$route} service in conjunction with the {@link api/ngRoute.directive:ngView ngView} directive. An
example of this technique is shown in the {@link tutorial/ angular tutorial}, in steps seven and
eight.

Expand Down
6 changes: 3 additions & 3 deletions docs/content/guide/directive.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ In this example we will build a directive that displays the current time.

# Writing directives (long version)

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

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

Therefore the above can be simplified as:

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

* `tElement` - template element - The element where the directive has been declared. It is
Expand Down
1 change: 1 addition & 0 deletions docs/src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
if (jQuery) addTag('script', {src: debug ? 'js/jquery.js' : 'js/jquery.min.js'});
addTag('script', {src: path('angular.js')}, sync);
addTag('script', {src: path('angular-resource.js') }, sync);
addTag('script', {src: path('angular-route.js') }, sync);
addTag('script', {src: path('angular-cookies.js') }, sync);
addTag('script', {src: path('angular-sanitize.js') }, sync);
addTag('script', {src: path('angular-mobile.js') }, sync);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/templates/js/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
};


angular.module('docsApp', ['ngResource', 'ngCookies', 'ngSanitize', 'bootstrap', 'bootstrapPrettify']).
angular.module('docsApp', ['ngResource', 'ngRoute', 'ngCookies', 'ngSanitize', 'bootstrap', 'bootstrapPrettify']).
config(function($locationProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
}).
Expand Down
3 changes: 0 additions & 3 deletions src/AngularPublic.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ function publishExternalAPI(angular){
ngSwitchWhen: ngSwitchWhenDirective,
ngSwitchDefault: ngSwitchDefaultDirective,
ngOptions: ngOptionsDirective,
ngView: ngViewDirective,
ngTransclude: ngTranscludeDirective,
ngModel: ngModelDirective,
ngList: ngListDirective,
Expand All @@ -122,8 +121,6 @@ function publishExternalAPI(angular){
$location: $LocationProvider,
$log: $LogProvider,
$parse: $ParseProvider,
$route: $RouteProvider,
$routeParams: $RouteParamsProvider,
$rootScope: $RootScopeProvider,
$q: $QProvider,
$sniffer: $SnifferProvider,
Expand Down
32 changes: 16 additions & 16 deletions src/ng/animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* | Directive | Supported Animations |
* |========================================================== |====================================================|
* | {@link ng.directive:ngRepeat#animations ngRepeat} | enter, leave and move |
* | {@link ng.directive:ngView#animations ngView} | enter and leave |
* | {@link ngRoute.directive:ngView#animations ngView} | enter and leave |
* | {@link ng.directive:ngInclude#animations ngInclude} | enter and leave |
* | {@link ng.directive:ngSwitch#animations ngSwitch} | enter and leave |
* | {@link ng.directive:ngIf#animations ngIf} | enter and leave |
Expand Down Expand Up @@ -183,7 +183,7 @@ var $AnimatorProvider = function() {
*/
var AnimatorService = function(scope, attrs) {
var animator = {};

/**
* @ngdoc function
* @name ng.animator#enter
Expand All @@ -198,7 +198,7 @@ var $AnimatorProvider = function() {
* @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
*/
animator.enter = animateActionFactory('enter', insert, noop);

/**
* @ngdoc function
* @name ng.animator#leave
Expand All @@ -212,7 +212,7 @@ var $AnimatorProvider = function() {
* @param {jQuery/jqLite element} parent the parent element of the element that will be the focus of the leave animation
*/
animator.leave = animateActionFactory('leave', noop, remove);

/**
* @ngdoc function
* @name ng.animator#move
Expand All @@ -228,7 +228,7 @@ var $AnimatorProvider = function() {
* @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
*/
animator.move = animateActionFactory('move', move, noop);

/**
* @ngdoc function
* @name ng.animator#show
Expand All @@ -241,7 +241,7 @@ var $AnimatorProvider = function() {
* @param {jQuery/jqLite element} element the element that will be rendered visible or hidden
*/
animator.show = animateActionFactory('show', show, noop);

/**
* @ngdoc function
* @name ng.animator#hide
Expand All @@ -262,14 +262,14 @@ var $AnimatorProvider = function() {
* @description
* Triggers a custom animation event to be executed on the given element
*
* @param {string} event the name of the custom event
* @param {string} event the name of the custom event
* @param {jQuery/jqLite element} element the element that will be animated
*/
animator.animate = function(event, element) {
animateActionFactory(event, noop, noop)(element);
}
return animator;

function animateActionFactory(type, beforeFn, afterFn) {
return function(element, parent, after) {
var ngAnimateValue = scope.$eval(attrs.ngAnimate);
Expand Down Expand Up @@ -329,18 +329,18 @@ var $AnimatorProvider = function() {
polyfillStart(element, done, memento);
} else if (isFunction($window.getComputedStyle)) {
//one day all browsers will have these properties
var w3cAnimationProp = 'animation';
var w3cAnimationProp = 'animation';
var w3cTransitionProp = 'transition';

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

var durationKey = 'Duration',
delayKey = 'Delay',
animationIterationCountKey = 'IterationCount',
duration = 0;

//we want all the styles defined before and after
var ELEMENT_NODE = 1;
forEach(element, function(element) {
Expand Down Expand Up @@ -387,15 +387,15 @@ var $AnimatorProvider = function() {
}
};
}

function show(element) {
element.css('display', '');
}

function hide(element) {
element.css('display', 'none');
}

function insert(element, parent, after) {
var afterNode = after && after[after.length - 1];
var parentNode = parent && parent[0] || afterNode && afterNode.parentNode;
Expand All @@ -408,11 +408,11 @@ var $AnimatorProvider = function() {
}
});
}

function remove(element) {
element.remove();
}

function move(element, parent, after) {
// Do not remove element before insert. Removing will cause data associated with the
// element to be dropped. Insert will implicitly do the remove.
Expand Down
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function $CompileProvider($provide) {
*/
this.directive = function registerDirective(name, directiveFactory) {
if (isString(name)) {
assertArg(directiveFactory, 'directive');
assertArg(directiveFactory, 'directiveFactory');
if (!hasDirectives.hasOwnProperty(name)) {
hasDirectives[name] = [];
$provide.factory(name + Suffix, ['$injector', '$exceptionHandler',
Expand Down
2 changes: 1 addition & 1 deletion src/ng/directive/ngController.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* * Controller — The `ngController` directive specifies a Controller class; the class has
* methods that typically express the business logic behind the application.
*
* Note that an alternative way to define controllers is via the {@link ng.$route $route} service.
* Note that an alternative way to define controllers is via the {@link ngRoute.$route $route} service.
*
* @element ANY
* @scope
Expand Down
Loading

0 comments on commit 5599b55

Please sign in to comment.