Commit da803b6b authored by Pascal Hartig's avatar Pascal Hartig

AngularJS: Upgrade to 1.2.14 (angular+routing)

parent 9b1f5af8
......@@ -2,11 +2,11 @@
"name": "todomvc-angular",
"version": "0.0.0",
"dependencies": {
"angular": "1.2.13",
"angular": "1.2.14",
"todomvc-common": "~0.1.4"
},
"devDependencies": {
"angular-mocks": "1.2.13",
"angular-route": "1.2.13"
"angular-mocks": "1.2.14",
"angular-route": "1.2.14"
}
}
/**
* @license AngularJS v1.2.13
* @license AngularJS v1.2.14
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {'use strict';
/**
* @ngdoc overview
* @ngdoc module
* @name ngRoute
* @description
*
......@@ -16,8 +16,7 @@
*
* ## Example
* See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`.
*
* {@installModule route}
*
*
* <div doc-module-components="ngRoute"></div>
*/
......@@ -26,14 +25,14 @@ var ngRouteModule = angular.module('ngRoute', ['ng']).
provider('$route', $RouteProvider);
/**
* @ngdoc object
* @name ngRoute.$routeProvider
* @ngdoc provider
* @name $routeProvider
* @function
*
* @description
*
* Used for configuring routes.
*
*
* ## Example
* See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`.
*
......@@ -49,27 +48,26 @@ function $RouteProvider(){
/**
* @ngdoc method
* @name ngRoute.$routeProvider#when
* @methodOf ngRoute.$routeProvider
* @name $routeProvider#when
*
* @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
* `$location.path` will be updated to add or drop the trailing slash to exactly match the
* 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`
* 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`
* 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
* `/color/brown/largecode/code/with/slashs/edit` and extract:
* `/color/brown/largecode/code/with/slashes/edit` and extract:
*
* * `color: brown`
* * `largecode: code/with/slashs`.
* * `color: brown`
* * `largecode: code/with/slashes`.
*
*
* @param {Object} route Mapping information to be assigned to `$route.current` on route
......@@ -89,7 +87,7 @@ function $RouteProvider(){
*
* 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
*
* - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html
......@@ -97,7 +95,7 @@ function $RouteProvider(){
*
* 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
*
* - `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should
......@@ -112,7 +110,7 @@ function $RouteProvider(){
*
* - `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.
* 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
* resolved before its value is injected into the controller. Be aware that
* `ngRoute.$routeParams` will still refer to the previous route within these resolve
......@@ -212,8 +210,7 @@ function $RouteProvider(){
/**
* @ngdoc method
* @name ngRoute.$routeProvider#otherwise
* @methodOf ngRoute.$routeProvider
* @name $routeProvider#otherwise
*
* @description
* Sets route definition that will be used on route change when no other route definition
......@@ -239,8 +236,8 @@ function $RouteProvider(){
function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) {
/**
* @ngdoc object
* @name ngRoute.$route
* @ngdoc service
* @name $route
* @requires $location
* @requires $routeParams
*
......@@ -255,7 +252,7 @@ function $RouteProvider(){
* - `$scope` - The current route scope.
* - `$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
* `$route` is used for deep-linking URLs to controllers and views (HTML partials).
......@@ -276,7 +273,7 @@ function $RouteProvider(){
Note that this example is using {@link ng.directive:script inlined templates}
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">
<div ng-controller="MainCntl">
Choose:
......@@ -309,7 +306,7 @@ function $RouteProvider(){
</file>
<file name="script.js">
angular.module('ngViewExample', ['ngRoute'])
angular.module('ngRouteExample', ['ngRoute'])
.config(function($routeProvider, $locationProvider) {
$routeProvider.when('/Book/:bookId', {
......@@ -350,17 +347,17 @@ function $RouteProvider(){
}
</file>
<file name="protractorTest.js">
<file name="protractor.js" type="protractor">
it('should load and compile correct template', function() {
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(/Book Id\: Moby/);
expect(content).toMatch(/Chapter Id\: 1/);
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(/Book Id\: Scarlet/);
});
......@@ -370,8 +367,7 @@ function $RouteProvider(){
/**
* @ngdoc event
* @name ngRoute.$route#$routeChangeStart
* @eventOf ngRoute.$route
* @name $route#$routeChangeStart
* @eventType broadcast on root scope
* @description
* Broadcasted before a route change. At this point the route services starts
......@@ -387,8 +383,7 @@ function $RouteProvider(){
/**
* @ngdoc event
* @name ngRoute.$route#$routeChangeSuccess
* @eventOf ngRoute.$route
* @name $route#$routeChangeSuccess
* @eventType broadcast on root scope
* @description
* Broadcasted after a route dependencies are resolved.
......@@ -403,8 +398,7 @@ function $RouteProvider(){
/**
* @ngdoc event
* @name ngRoute.$route#$routeChangeError
* @eventOf ngRoute.$route
* @name $route#$routeChangeError
* @eventType broadcast on root scope
* @description
* Broadcasted if any of the resolve promises are rejected.
......@@ -417,8 +411,7 @@ function $RouteProvider(){
/**
* @ngdoc event
* @name ngRoute.$route#$routeUpdate
* @eventOf ngRoute.$route
* @name $route#$routeUpdate
* @eventType broadcast on root scope
* @description
*
......@@ -432,8 +425,7 @@ function $RouteProvider(){
/**
* @ngdoc method
* @name ngRoute.$route#reload
* @methodOf ngRoute.$route
* @name $route#reload
*
* @description
* Causes `$route` service to reload the current route even if
......@@ -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() {
// Match a route
......@@ -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) {
var result = [];
......@@ -607,8 +599,8 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider);
/**
* @ngdoc object
* @name ngRoute.$routeParams
* @ngdoc service
* @name $routeParams
* @requires $route
*
* @description
......@@ -617,7 +609,7 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider);
* Requires the {@link ngRoute `ngRoute`} module to be installed.
*
* 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.
*
* In case of parameter name collision, `path` params take precedence over `search` params.
......@@ -630,14 +622,14 @@ ngRouteModule.provider('$routeParams', $RouteParamsProvider);
* Instead you can use `$route.current.params` to access the new route's parameters.
*
* @example
* <pre>
* ```js
* // Given:
* // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby
* // Route: /Chapter/:chapterId/Section/:sectionId
* //
* // Then
* $routeParams ==> {chapterId:1, sectionId:2, search:'moby'}
* </pre>
* ```
*/
function $RouteParamsProvider() {
this.$get = function() { return {}; };
......@@ -649,7 +641,7 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
/**
* @ngdoc directive
* @name ngRoute.directive:ngView
* @name ngView
* @restrict ECA
*
* @description
......@@ -679,7 +671,9 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
* - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated
* as an expression yields a truthy value.
* @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">
<div ng-controller="MainCntl as main">
Choose:
......@@ -794,17 +788,17 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
}
</file>
<file name="protractorTest.js">
<file name="protractor.js" type="protractor">
it('should load and compile correct template', function() {
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(/Book Id\: Moby/);
expect(content).toMatch(/Chapter Id\: 1/);
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(/Book Id\: Scarlet/);
});
......@@ -815,8 +809,7 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
/**
* @ngdoc event
* @name ngRoute.directive:ngView#$viewContentLoaded
* @eventOf ngRoute.directive:ngView
* @name ngView#$viewContentLoaded
* @eventType emit on the current ngView scope
* @description
* Emitted every time the ngView content is reloaded.
......@@ -831,6 +824,7 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
link: function(scope, $element, attr, ctrl, $transclude) {
var currentScope,
currentElement,
previousElement,
autoScrollExp = attr.autoscroll,
onloadExp = attr.onload || '';
......@@ -838,12 +832,19 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
update();
function cleanupLastView() {
if (currentScope) {
if(previousElement) {
previousElement.remove();
previousElement = null;
}
if(currentScope) {
currentScope.$destroy();
currentScope = null;
}
if(currentElement) {
$animate.leave(currentElement);
$animate.leave(currentElement, function() {
previousElement = null;
});
previousElement = currentElement;
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