Commit da803b6b authored by Pascal Hartig's avatar Pascal Hartig

AngularJS: Upgrade to 1.2.14 (angular+routing)

parent 9b1f5af8
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
"name": "todomvc-angular", "name": "todomvc-angular",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"angular": "1.2.13", "angular": "1.2.14",
"todomvc-common": "~0.1.4" "todomvc-common": "~0.1.4"
}, },
"devDependencies": { "devDependencies": {
"angular-mocks": "1.2.13", "angular-mocks": "1.2.14",
"angular-route": "1.2.13" "angular-route": "1.2.14"
} }
} }
/** /**
* @license AngularJS v1.2.13 * @license AngularJS v1.2.14
* (c) 2010-2014 Google, Inc. http://angularjs.org * (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT * License: MIT
*/ */
(function(window, angular, undefined) {'use strict'; (function(window, angular, undefined) {'use strict';
/** /**
* @ngdoc overview * @ngdoc module
* @name ngRoute * @name ngRoute
* @description * @description
* *
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
* *
* ## Example * ## Example
* See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`.
* *
* {@installModule route}
* *
* <div doc-module-components="ngRoute"></div> * <div doc-module-components="ngRoute"></div>
*/ */
...@@ -26,14 +25,14 @@ var ngRouteModule = angular.module('ngRoute', ['ng']). ...@@ -26,14 +25,14 @@ var ngRouteModule = angular.module('ngRoute', ['ng']).
provider('$route', $RouteProvider); provider('$route', $RouteProvider);
/** /**
* @ngdoc object * @ngdoc provider
* @name ngRoute.$routeProvider * @name $routeProvider
* @function * @function
* *
* @description * @description
* *
* Used for configuring routes. * Used for configuring routes.
* *
* ## Example * ## Example
* See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`.
* *
...@@ -49,27 +48,26 @@ function $RouteProvider(){ ...@@ -49,27 +48,26 @@ function $RouteProvider(){
/** /**
* @ngdoc method * @ngdoc method
* @name ngRoute.$routeProvider#when * @name $routeProvider#when
* @methodOf ngRoute.$routeProvider
* *
* @param {string} path Route path (matched against `$location.path`). If `$location.path` * @param {string} path Route path (matched against `$location.path`). If `$location.path`
* contains redundant trailing slash or is missing one, the route will still match and the * contains redundant trailing slash or is missing one, the route will still match and the
* `$location.path` will be updated to add or drop the trailing slash to exactly match the * `$location.path` will be updated to add or drop the trailing slash to exactly match the
* route definition. * route definition.
* *
* * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up * * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up
* to the next slash are matched and stored in `$routeParams` under the given `name` * to the next slash are matched and stored in `$routeParams` under the given `name`
* when the route matches. * when the route matches.
* * `path` can contain named groups starting with a colon and ending with a star: * * `path` can contain named groups starting with a colon and ending with a star:
* e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name` * e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name`
* when the route matches. * when the route matches.
* * `path` can contain optional named groups with a question mark: e.g.`:name?`. * * `path` can contain optional named groups with a question mark: e.g.`:name?`.
* *
* For example, routes like `/color/:color/largecode/:largecode*\/edit` will match * For example, routes like `/color/:color/largecode/:largecode*\/edit` will match
* `/color/brown/largecode/code/with/slashs/edit` and extract: * `/color/brown/largecode/code/with/slashes/edit` and extract:
* *
* * `color: brown` * * `color: brown`
* * `largecode: code/with/slashs`. * * `largecode: code/with/slashes`.
* *
* *
* @param {Object} route Mapping information to be assigned to `$route.current` on route * @param {Object} route Mapping information to be assigned to `$route.current` on route
...@@ -89,7 +87,7 @@ function $RouteProvider(){ ...@@ -89,7 +87,7 @@ function $RouteProvider(){
* *
* If `template` is a function, it will be called with the following parameters: * If `template` is a function, it will be called with the following parameters:
* *
* - `{Array.<Object>}` - route parameters extracted from the current * - `{Array.&lt;Object&gt;}` - route parameters extracted from the current
* `$location.path()` by applying the current route * `$location.path()` by applying the current route
* *
* - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html * - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html
...@@ -97,7 +95,7 @@ function $RouteProvider(){ ...@@ -97,7 +95,7 @@ function $RouteProvider(){
* *
* If `templateUrl` is a function, it will be called with the following parameters: * If `templateUrl` is a function, it will be called with the following parameters:
* *
* - `{Array.<Object>}` - route parameters extracted from the current * - `{Array.&lt;Object&gt;}` - route parameters extracted from the current
* `$location.path()` by applying the current route * `$location.path()` by applying the current route
* *
* - `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should * - `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should
...@@ -112,7 +110,7 @@ function $RouteProvider(){ ...@@ -112,7 +110,7 @@ function $RouteProvider(){
* *
* - `key` – `{string}`: a name of a dependency to be injected into the controller. * - `key` – `{string}`: a name of a dependency to be injected into the controller.
* - `factory` - `{string|function}`: If `string` then it is an alias for a service. * - `factory` - `{string|function}`: If `string` then it is an alias for a service.
* Otherwise if function, then it is {@link api/AUTO.$injector#invoke injected} * Otherwise if function, then it is {@link auto.$injector#invoke injected}
* and the return value is treated as the dependency. If the result is a promise, it is * and the return value is treated as the dependency. If the result is a promise, it is
* resolved before its value is injected into the controller. Be aware that * resolved before its value is injected into the controller. Be aware that
* `ngRoute.$routeParams` will still refer to the previous route within these resolve * `ngRoute.$routeParams` will still refer to the previous route within these resolve
...@@ -212,8 +210,7 @@ function $RouteProvider(){ ...@@ -212,8 +210,7 @@ function $RouteProvider(){
/** /**
* @ngdoc method * @ngdoc method
* @name ngRoute.$routeProvider#otherwise * @name $routeProvider#otherwise
* @methodOf ngRoute.$routeProvider
* *
* @description * @description
* Sets route definition that will be used on route change when no other route definition * Sets route definition that will be used on route change when no other route definition
...@@ -239,8 +236,8 @@ function $RouteProvider(){ ...@@ -239,8 +236,8 @@ function $RouteProvider(){
function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) { function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) {
/** /**
* @ngdoc object * @ngdoc service
* @name ngRoute.$route * @name $route
* @requires $location * @requires $location
* @requires $routeParams * @requires $routeParams
* *
...@@ -255,7 +252,7 @@ function $RouteProvider(){ ...@@ -255,7 +252,7 @@ function $RouteProvider(){
* - `$scope` - The current route scope. * - `$scope` - The current route scope.
* - `$template` - The current route template HTML. * - `$template` - The current route template HTML.
* *
* @property {Array.<Object>} routes Array of all configured routes. * @property {Array.&lt;Object&gt;} routes Array of all configured routes.
* *
* @description * @description
* `$route` is used for deep-linking URLs to controllers and views (HTML partials). * `$route` is used for deep-linking URLs to controllers and views (HTML partials).
...@@ -276,7 +273,7 @@ function $RouteProvider(){ ...@@ -276,7 +273,7 @@ function $RouteProvider(){
Note that this example is using {@link ng.directive:script inlined templates} Note that this example is using {@link ng.directive:script inlined templates}
to get it working on jsfiddle as well. to get it working on jsfiddle as well.
<example module="ngViewExample" deps="angular-route.js"> <example name="$route-service" module="ngRouteExample" deps="angular-route.js" fixBase="true">
<file name="index.html"> <file name="index.html">
<div ng-controller="MainCntl"> <div ng-controller="MainCntl">
Choose: Choose:
...@@ -309,7 +306,7 @@ function $RouteProvider(){ ...@@ -309,7 +306,7 @@ function $RouteProvider(){
</file> </file>
<file name="script.js"> <file name="script.js">
angular.module('ngViewExample', ['ngRoute']) angular.module('ngRouteExample', ['ngRoute'])
.config(function($routeProvider, $locationProvider) { .config(function($routeProvider, $locationProvider) {
$routeProvider.when('/Book/:bookId', { $routeProvider.when('/Book/:bookId', {
...@@ -350,17 +347,17 @@ function $RouteProvider(){ ...@@ -350,17 +347,17 @@ function $RouteProvider(){
} }
</file> </file>
<file name="protractorTest.js"> <file name="protractor.js" type="protractor">
it('should load and compile correct template', function() { it('should load and compile correct template', function() {
element(by.linkText('Moby: Ch1')).click(); element(by.linkText('Moby: Ch1')).click();
var content = element(by.css('.doc-example-live [ng-view]')).getText(); var content = element(by.css('[ng-view]')).getText();
expect(content).toMatch(/controller\: ChapterCntl/); expect(content).toMatch(/controller\: ChapterCntl/);
expect(content).toMatch(/Book Id\: Moby/); expect(content).toMatch(/Book Id\: Moby/);
expect(content).toMatch(/Chapter Id\: 1/); expect(content).toMatch(/Chapter Id\: 1/);
element(by.partialLinkText('Scarlet')).click(); element(by.partialLinkText('Scarlet')).click();
content = element(by.css('.doc-example-live [ng-view]')).getText(); content = element(by.css('[ng-view]')).getText();
expect(content).toMatch(/controller\: BookCntl/); expect(content).toMatch(/controller\: BookCntl/);
expect(content).toMatch(/Book Id\: Scarlet/); expect(content).toMatch(/Book Id\: Scarlet/);
}); });
...@@ -370,8 +367,7 @@ function $RouteProvider(){ ...@@ -370,8 +367,7 @@ function $RouteProvider(){
/** /**
* @ngdoc event * @ngdoc event
* @name ngRoute.$route#$routeChangeStart * @name $route#$routeChangeStart
* @eventOf ngRoute.$route
* @eventType broadcast on root scope * @eventType broadcast on root scope
* @description * @description
* Broadcasted before a route change. At this point the route services starts * Broadcasted before a route change. At this point the route services starts
...@@ -387,8 +383,7 @@ function $RouteProvider(){ ...@@ -387,8 +383,7 @@ function $RouteProvider(){
/** /**
* @ngdoc event * @ngdoc event
* @name ngRoute.$route#$routeChangeSuccess * @name $route#$routeChangeSuccess
* @eventOf ngRoute.$route
* @eventType broadcast on root scope * @eventType broadcast on root scope
* @description * @description
* Broadcasted after a route dependencies are resolved. * Broadcasted after a route dependencies are resolved.
...@@ -403,8 +398,7 @@ function $RouteProvider(){ ...@@ -403,8 +398,7 @@ function $RouteProvider(){
/** /**
* @ngdoc event * @ngdoc event
* @name ngRoute.$route#$routeChangeError * @name $route#$routeChangeError
* @eventOf ngRoute.$route
* @eventType broadcast on root scope * @eventType broadcast on root scope
* @description * @description
* Broadcasted if any of the resolve promises are rejected. * Broadcasted if any of the resolve promises are rejected.
...@@ -417,8 +411,7 @@ function $RouteProvider(){ ...@@ -417,8 +411,7 @@ function $RouteProvider(){
/** /**
* @ngdoc event * @ngdoc event
* @name ngRoute.$route#$routeUpdate * @name $route#$routeUpdate
* @eventOf ngRoute.$route
* @eventType broadcast on root scope * @eventType broadcast on root scope
* @description * @description
* *
...@@ -432,8 +425,7 @@ function $RouteProvider(){ ...@@ -432,8 +425,7 @@ function $RouteProvider(){
/** /**
* @ngdoc method * @ngdoc method
* @name ngRoute.$route#reload * @name $route#reload
* @methodOf ngRoute.$route
* *
* @description * @description
* Causes `$route` service to reload the current route even if * Causes `$route` service to reload the current route even if
...@@ -565,7 +557,7 @@ function $RouteProvider(){ ...@@ -565,7 +557,7 @@ function $RouteProvider(){
/** /**
* @returns the current active route, by matching it against the URL * @returns {Object} the current active route, by matching it against the URL
*/ */
function parseRoute() { function parseRoute() {
// Match a route // Match a route
...@@ -583,7 +575,7 @@ function $RouteProvider(){ ...@@ -583,7 +575,7 @@ function $RouteProvider(){
} }
/** /**
* @returns interpolation of the redirect path with the parameters * @returns {string} interpolation of the redirect path with the parameters
*/ */
function interpolate(string, params) { function interpolate(string, params) {
var result = []; var result = [];
...@@ -607,8 +599,8 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider); ...@@ -607,8 +599,8 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider);
/** /**
* @ngdoc object * @ngdoc service
* @name ngRoute.$routeParams * @name $routeParams
* @requires $route * @requires $route
* *
* @description * @description
...@@ -617,7 +609,7 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider); ...@@ -617,7 +609,7 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider);
* Requires the {@link ngRoute `ngRoute`} module to be installed. * Requires the {@link ngRoute `ngRoute`} module to be installed.
* *
* The route parameters are a combination of {@link ng.$location `$location`}'s * The route parameters are a combination of {@link ng.$location `$location`}'s
* {@link ng.$location#methods_search `search()`} and {@link ng.$location#methods_path `path()`}. * {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}.
* The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched. * The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched.
* *
* In case of parameter name collision, `path` params take precedence over `search` params. * In case of parameter name collision, `path` params take precedence over `search` params.
...@@ -630,14 +622,14 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider); ...@@ -630,14 +622,14 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider);
* Instead you can use `$route.current.params` to access the new route's parameters. * Instead you can use `$route.current.params` to access the new route's parameters.
* *
* @example * @example
* <pre> * ```js
* // Given: * // Given:
* // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby * // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
* // Route: /Chapter/:chapterId/Section/:sectionId * // Route: /Chapter/:chapterId/Section/:sectionId
* // * //
* // Then * // Then
* $routeParams ==> {chapterId:1, sectionId:2, search:'moby'} * $routeParams ==> {chapterId:1, sectionId:2, search:'moby'}
* </pre> * ```
*/ */
function $RouteParamsProvider() { function $RouteParamsProvider() {
this.$get = function() { return {}; }; this.$get = function() { return {}; };
...@@ -649,7 +641,7 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory); ...@@ -649,7 +641,7 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
/** /**
* @ngdoc directive * @ngdoc directive
* @name ngRoute.directive:ngView * @name ngView
* @restrict ECA * @restrict ECA
* *
* @description * @description
...@@ -679,7 +671,9 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory); ...@@ -679,7 +671,9 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
* - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated * - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated
* as an expression yields a truthy value. * as an expression yields a truthy value.
* @example * @example
<example module="ngViewExample" deps="angular-route.js" animations="true"> <example name="ngView-directive" module="ngViewExample"
deps="angular-route.js;angular-animate.js"
animations="true" fixBase="true">
<file name="index.html"> <file name="index.html">
<div ng-controller="MainCntl as main"> <div ng-controller="MainCntl as main">
Choose: Choose:
...@@ -794,17 +788,17 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory); ...@@ -794,17 +788,17 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
} }
</file> </file>
<file name="protractorTest.js"> <file name="protractor.js" type="protractor">
it('should load and compile correct template', function() { it('should load and compile correct template', function() {
element(by.linkText('Moby: Ch1')).click(); element(by.linkText('Moby: Ch1')).click();
var content = element(by.css('.doc-example-live [ng-view]')).getText(); var content = element(by.css('[ng-view]')).getText();
expect(content).toMatch(/controller\: ChapterCntl/); expect(content).toMatch(/controller\: ChapterCntl/);
expect(content).toMatch(/Book Id\: Moby/); expect(content).toMatch(/Book Id\: Moby/);
expect(content).toMatch(/Chapter Id\: 1/); expect(content).toMatch(/Chapter Id\: 1/);
element(by.partialLinkText('Scarlet')).click(); element(by.partialLinkText('Scarlet')).click();
content = element(by.css('.doc-example-live [ng-view]')).getText(); content = element(by.css('[ng-view]')).getText();
expect(content).toMatch(/controller\: BookCntl/); expect(content).toMatch(/controller\: BookCntl/);
expect(content).toMatch(/Book Id\: Scarlet/); expect(content).toMatch(/Book Id\: Scarlet/);
}); });
...@@ -815,8 +809,7 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory); ...@@ -815,8 +809,7 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
/** /**
* @ngdoc event * @ngdoc event
* @name ngRoute.directive:ngView#$viewContentLoaded * @name ngView#$viewContentLoaded
* @eventOf ngRoute.directive:ngView
* @eventType emit on the current ngView scope * @eventType emit on the current ngView scope
* @description * @description
* Emitted every time the ngView content is reloaded. * Emitted every time the ngView content is reloaded.
...@@ -831,6 +824,7 @@ function ngViewFactory( $route, $anchorScroll, $animate) { ...@@ -831,6 +824,7 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
link: function(scope, $element, attr, ctrl, $transclude) { link: function(scope, $element, attr, ctrl, $transclude) {
var currentScope, var currentScope,
currentElement, currentElement,
previousElement,
autoScrollExp = attr.autoscroll, autoScrollExp = attr.autoscroll,
onloadExp = attr.onload || ''; onloadExp = attr.onload || '';
...@@ -838,12 +832,19 @@ function ngViewFactory( $route, $anchorScroll, $animate) { ...@@ -838,12 +832,19 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
update(); update();
function cleanupLastView() { function cleanupLastView() {
if (currentScope) { if(previousElement) {
previousElement.remove();
previousElement = null;
}
if(currentScope) {
currentScope.$destroy(); currentScope.$destroy();
currentScope = null; currentScope = null;
} }
if(currentElement) { if(currentElement) {
$animate.leave(currentElement); $animate.leave(currentElement, function() {
previousElement = null;
});
previousElement = currentElement;
currentElement = null; currentElement = null;
} }
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment