Compare commits
132 Commits
v1.2.24
...
v1.3.0-beta.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f2d756532 | |||
| 6011145cfe | |||
| b26fc23b06 | |||
| 0c930a1a86 | |||
| 2f61b2f045 | |||
| 4d4da556eb | |||
| 58f5da8664 | |||
| fb6062fb9d | |||
| 0c65f1ae3e | |||
| f40f54c6da | |||
| 37bc5ef4d8 | |||
| 3652831084 | |||
| bc42950b51 | |||
| 6680b7b97c | |||
| c839f78b8f | |||
| f7ce415c67 | |||
| 4cf2adfeda | |||
| 2b84f43a6d | |||
| d6cfcacee1 | |||
| 299b220f5e | |||
| 78057a945e | |||
| c5e41a0325 | |||
| 748a6c8d9d | |||
| ed4cd6c3c6 | |||
| 4cc00e7aed | |||
| f7b36844e6 | |||
| 959297c38a | |||
| f8f97f8b61 | |||
| 2ca6d650e8 | |||
| 547871e779 | |||
| a4b70cfd71 | |||
| c9fbb472b7 | |||
| df6d34c52b | |||
| ed22869e08 | |||
| ee07b502a2 | |||
| 63ec18f5c9 | |||
| e381c4dd09 | |||
| 68e84acec9 | |||
| e118a8be34 | |||
| 9202767f41 | |||
| 7fb88698dc | |||
| bdcc657c7e | |||
| c995b09b77 | |||
| 8a96f317e5 | |||
| d3aa14bc11 | |||
| cd49876e34 | |||
| 55a0bc453c | |||
| 2daaf3ea19 | |||
| e1484cdf65 | |||
| d0781eb1a3 | |||
| d09056d287 | |||
| 849e4472e1 | |||
| f55278fa8a | |||
| df5624147f | |||
| 91e6d1d22f | |||
| b8cc71d476 | |||
| 511422adb0 | |||
| dd3587a8c1 | |||
| e5dd832b20 | |||
| a15d9cb4b6 | |||
| 9bfbb16e23 | |||
| 2b741dc8b8 | |||
| e888dde3c5 | |||
| d5294ebfa0 | |||
| 6d6ebf7c61 | |||
| 44b940e88d | |||
| 56e73ea355 | |||
| bfb6af7053 | |||
| d7be9588a0 | |||
| 53e4da8eab | |||
| 7b5e019981 | |||
| 129e2e021a | |||
| 3cc02e7f03 | |||
| 79592ce9e2 | |||
| a9a38d84b9 | |||
| 24a67f9515 | |||
| 91ef3a31a0 | |||
| cea44b3e86 | |||
| e8c6b9bf25 | |||
| 5412372e93 | |||
| 4f823f902d | |||
| fe0e434a87 | |||
| edad4e63df | |||
| f684cb09a5 | |||
| d7717d93e4 | |||
| 247ec19c82 | |||
| 78165c224d | |||
| d1214af132 | |||
| 11c5bb7f3d | |||
| d6419d0aff | |||
| 55848a9139 | |||
| 0f13f24ad2 | |||
| 0d8de2d3ea | |||
| 7833ce0a6e | |||
| 47ab8df455 | |||
| b700282ffd | |||
| 1b9395ea8f | |||
| 44d160e3ce | |||
| 4f90c9b531 | |||
| 11aceac273 | |||
| f08bf6f1f7 | |||
| ca4ddfadba | |||
| 4bab3d8227 | |||
| b12c6b485d | |||
| 9c353b4f17 | |||
| 21243d62a2 | |||
| ad309b1332 | |||
| 7a75356388 | |||
| dc57fe97e1 | |||
| 853999de10 | |||
| 53ec5e13e5 | |||
| 235731d32b | |||
| 5af8d2963b | |||
| 0b4a41af58 | |||
| 0e066693f2 | |||
| 02cc2b2014 | |||
| 486f1b4e51 | |||
| c5f2f583ab | |||
| 186a68f8ff | |||
| 46bd6dc88d | |||
| 0609453e1f | |||
| 7682e5747a | |||
| eaa1d00b24 | |||
| 3cf2da0e38 | |||
| 9335378602 | |||
| de2ecb8a96 | |||
| 66fdc03642 | |||
| 8e2e9adb46 | |||
| 7d604975a7 | |||
| 02075dcf13 | |||
| 7c73bc916e | |||
| 2036fb1e71 |
+2
-1
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"disallowKeywords": ["with"],
|
||||
"disallowTrailingWhitespace": true,
|
||||
"requireRightStickedOperators": ["!"]
|
||||
"requireRightStickedOperators": ["!"],
|
||||
"requireLeftStickedOperators": [","]
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
|
||||
"disallowLeftStickedOperators": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
|
||||
"disallowRightStickedOperators": ["?", "+", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
|
||||
"requireLeftStickedOperators": [","],
|
||||
"disallowImplicitTypeConversion": ["string"],
|
||||
"disallowMultipleLineBreaks": true,
|
||||
"disallowKeywordsOnNewLine": ["else"],
|
||||
|
||||
+162
-15
@@ -1,3 +1,150 @@
|
||||
<a name="1.3.0-beta.3"></a>
|
||||
# 1.3.0-beta.3 emotional-waffles (2014-03-21)
|
||||
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **ngAnimate:** support `webkitCancelRequestAnimationFrame` in addition to `webkitCancelAnimationFrame`
|
||||
([c839f78b](https://github.com/angular/angular.js/commit/c839f78b8f2d8d910bc2bfc9e41b3e3b67090ec1),
|
||||
[#6526](https://github.com/angular/angular.js/issues/6526))
|
||||
- **$http:** allow sending Blob data using `$http`
|
||||
([b8cc71d4](https://github.com/angular/angular.js/commit/b8cc71d476f76ff51e719fb76fb2348027c858ce),
|
||||
[#5012](https://github.com/angular/angular.js/issues/5012))
|
||||
- **$httpBackend:** don't error when JSONP callback is called with no parameter
|
||||
([6680b7b9](https://github.com/angular/angular.js/commit/6680b7b97c0326a80bdccaf0a35031e4af641e0e),
|
||||
[#4987](https://github.com/angular/angular.js/issues/4987), [#6735](https://github.com/angular/angular.js/issues/6735))
|
||||
- **$rootScope:** ng-repeat can't handle `NaN` values. #4605
|
||||
([fb6062fb](https://github.com/angular/angular.js/commit/fb6062fb9d83545730b993e94ac7482ffd43a62c),
|
||||
[#4605](https://github.com/angular/angular.js/issues/4605))
|
||||
- **$rootScope:** `$watchCollection` should call listener with old value
|
||||
([78057a94](https://github.com/angular/angular.js/commit/78057a945ef84cbb05f9417fe884cb8c28e67b44),
|
||||
[#2621](https://github.com/angular/angular.js/issues/2621), [#5661](https://github.com/angular/angular.js/issues/5661), [#5688](https://github.com/angular/angular.js/issues/5688), [#6736](https://github.com/angular/angular.js/issues/6736))
|
||||
- **angular.bootstrap:** allow angular to load only once
|
||||
([748a6c8d](https://github.com/angular/angular.js/commit/748a6c8d9d8d61c3ee18eec462abe8ff245d6a98),
|
||||
[#5863](https://github.com/angular/angular.js/issues/5863), [#5587](https://github.com/angular/angular.js/issues/5587))
|
||||
- **jqLite:** `inheritedData()` now traverses Shadow DOM boundaries via the `host` property of `DocumentFragment`
|
||||
([8a96f317](https://github.com/angular/angular.js/commit/8a96f317e594a5096d4fa56ceae4c685eec8ac8b),
|
||||
[#6637](https://github.com/angular/angular.js/issues/6637))
|
||||
- **ngCookie:** convert non-string values to string
|
||||
([36528310](https://github.com/angular/angular.js/commit/3652831084c3788f786046b907a7361d2e89c520),
|
||||
[#6151](https://github.com/angular/angular.js/issues/6151), [#6220](https://github.com/angular/angular.js/issues/6220))
|
||||
- **ngTouch:** update workaround for Webkit quirk
|
||||
([bc42950b](https://github.com/angular/angular.js/commit/bc42950b514b60f319812eeb87aae2915e394237),
|
||||
[#6302](https://github.com/angular/angular.js/issues/6302))
|
||||
- **orderBy:** support string predicates containing non-ident characters
|
||||
([37bc5ef4](https://github.com/angular/angular.js/commit/37bc5ef4d87f19da47d3ab454c43d1e532c4f924),
|
||||
[#6143](https://github.com/angular/angular.js/issues/6143), [#6144](https://github.com/angular/angular.js/issues/6144))
|
||||
- **select:** avoid checking option element's `selected` property in render
|
||||
([f40f54c6](https://github.com/angular/angular.js/commit/f40f54c6da4a5399fe18a89d068634bb491e9f1a),
|
||||
[#2448](https://github.com/angular/angular.js/issues/2448), [#5994](https://github.com/angular/angular.js/issues/5994))
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- **$compile:** add support for `$observer` deregistration
|
||||
([299b220f](https://github.com/angular/angular.js/commit/299b220f5e05e1d4e26bfd58d0b2fd7329ca76b1),
|
||||
[#5609](https://github.com/angular/angular.js/issues/5609))
|
||||
- **ngMock.$httpBackend:** added support for function as URL matcher
|
||||
([d6cfcace](https://github.com/angular/angular.js/commit/d6cfcacee101f2738e0a224a3377232ff85f78a4),
|
||||
[#4580](https://github.com/angular/angular.js/issues/4580))
|
||||
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
- **$compile:** due to [299b220f](https://github.com/angular/angular.js/commit/299b220f5e05e1d4e26bfd58d0b2fd7329ca76b1),
|
||||
calling `attr.$observe` no longer returns the observer function, but a
|
||||
deregistration function instead. To migrate the code follow the example below:
|
||||
|
||||
Before:
|
||||
|
||||
directive('directiveName', function() {
|
||||
return {
|
||||
link: function(scope, elm, attr) {
|
||||
var observer = attr.$observe('someAttr', function(value) {
|
||||
console.log(value);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
After:
|
||||
|
||||
directive('directiveName', function() {
|
||||
return {
|
||||
link: function(scope, elm, attr) {
|
||||
var observer = function(value) {
|
||||
console.log(value);
|
||||
};
|
||||
|
||||
attr.$observe('someAttr', observer);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
- **$httpBackend:** due to [6680b7b9](https://github.com/angular/angular.js/commit/6680b7b97c0326a80bdccaf0a35031e4af641e0e), the JSONP behavior for erroneous and empty responses changed:
|
||||
Previously, a JSONP response was regarded as erroneous if it was empty. Now Angular is listening to the
|
||||
correct events to detect errors, i.e. even empty responses can be successful.
|
||||
|
||||
|
||||
|
||||
<a name="1.3.0-beta.2"></a>
|
||||
# 1.3.0-beta.2 silent-ventriloquism (2014-03-14)
|
||||
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **$$rAF:** always fallback to a $timeout in case native rAF isn't supported
|
||||
([7b5e0199](https://github.com/angular/angular.js/commit/7b5e019981f352add88be2984de68e553d1bfa93),
|
||||
[#6654](https://github.com/angular/angular.js/issues/6654))
|
||||
- **$http:** don't convert 0 status codes to 404 for non-file protocols
|
||||
([56e73ea3](https://github.com/angular/angular.js/commit/56e73ea355c851fdfd574d6d2a9e2fcb75677945),
|
||||
[#6074](https://github.com/angular/angular.js/issues/6074), [#6155](https://github.com/angular/angular.js/issues/6155))
|
||||
- **ngAnimate:** setting classNameFilter disables animation inside ng-if
|
||||
([129e2e02](https://github.com/angular/angular.js/commit/129e2e021ab1d773874428cd1fb329eae72797c4),
|
||||
[#6539](https://github.com/angular/angular.js/issues/6539))
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- whitelist blob urls for sanitization of data-bound image urls
|
||||
([47ab8df4](https://github.com/angular/angular.js/commit/47ab8df455df1f1391b760e1fbcc5c21645512b8),
|
||||
[#4623](https://github.com/angular/angular.js/issues/4623))
|
||||
|
||||
|
||||
|
||||
<a name="1.3.0-beta.1"></a>
|
||||
# 1.3.0-beta.1 retractable-eyebrow (2014-03-07)
|
||||
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **$compile:** support templates with thead and tfoot root elements
|
||||
([53ec5e13](https://github.com/angular/angular.js/commit/53ec5e13e5955830b6751019eef232bd2125c0b6),
|
||||
[#6289](https://github.com/angular/angular.js/issues/6289))
|
||||
- **style:** expressions in style tags
|
||||
([0609453e](https://github.com/angular/angular.js/commit/0609453e1f9ae074f8d786df903096a6eadb6aa0),
|
||||
[#2387](https://github.com/angular/angular.js/issues/2387), [#6492](https://github.com/angular/angular.js/issues/6492))
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- **input:** support types date, time, datetime-local, month, week
|
||||
([46bd6dc8](https://github.com/angular/angular.js/commit/46bd6dc88de252886d75426efc2ce8107a5134e9),
|
||||
[#5864](https://github.com/angular/angular.js/issues/5864))
|
||||
|
||||
|
||||
## Breaking Changes
|
||||
|
||||
- **build:** due to [eaa1d00b](https://github.com/angular/angular.js/commit/eaa1d00b24008f590b95ad099241b4003688cdda),
|
||||
As communicated before, IE8 is no longer supported.
|
||||
- **input:** types date, time, datetime-local, month, week now always
|
||||
require a `Date` object as model ([46bd6dc8](https://github.com/angular/angular.js/commit/46bd6dc88de252886d75426efc2ce8107a5134e9),
|
||||
[#5864](https://github.com/angular/angular.js/issues/5864))
|
||||
|
||||
For more info: http://blog.angularjs.org/2013/12/angularjs-13-new-release-approaches.html
|
||||
|
||||
|
||||
|
||||
<a name="1.2.14"></a>
|
||||
# 1.2.14 feisty-cryokinesis (2014-03-01)
|
||||
|
||||
@@ -275,26 +422,26 @@ The animation mock module has been renamed from `mock.animate` to `ngAnimateMock
|
||||
## Breaking Changes
|
||||
|
||||
- **$http:** due to [e1cfb195](https://github.com/angular/angular.js/commit/e1cfb1957feaf89408bccf48fae6f529e57a82fe),
|
||||
it is now necessary to separately specify default HTTP headers for PUT, POST and PATCH requests, as these no longer share a single object.
|
||||
it is now necessary to separately specify default HTTP headers for PUT, POST and PATCH requests, as these no longer share a single object.
|
||||
|
||||
To migrate your code, follow the example below:
|
||||
To migrate your code, follow the example below:
|
||||
|
||||
Before:
|
||||
Before:
|
||||
|
||||
// Will apply to POST, PUT and PATCH methods
|
||||
$httpProvider.defaults.headers.post = {
|
||||
"X-MY-CSRF-HEADER": "..."
|
||||
};
|
||||
// Will apply to POST, PUT and PATCH methods
|
||||
$httpProvider.defaults.headers.post = {
|
||||
"X-MY-CSRF-HEADER": "..."
|
||||
};
|
||||
|
||||
After:
|
||||
After:
|
||||
|
||||
// POST, PUT and PATCH default headers must be specified separately,
|
||||
// as they do not share data.
|
||||
$httpProvider.defaults.headers.post =
|
||||
$httpProvider.defaults.headers.put =
|
||||
$httpProviders.defaults.headers.patch = {
|
||||
"X-MY-CSRF-HEADER": "..."
|
||||
};
|
||||
// POST, PUT and PATCH default headers must be specified separately,
|
||||
// as they do not share data.
|
||||
$httpProvider.defaults.headers.post =
|
||||
$httpProvider.defaults.headers.put =
|
||||
$httpProviders.defaults.headers.patch = {
|
||||
"X-MY-CSRF-HEADER": "..."
|
||||
};
|
||||
|
||||
<a name="1.2.8"></a>
|
||||
# 1.2.8 interdimensional-cartography (2014-01-10)
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
var files = require('./angularFiles').files;
|
||||
var util = require('./lib/grunt/utils.js');
|
||||
var versionInfo = require('./lib/versions/version-info');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(grunt) {
|
||||
@@ -8,10 +9,10 @@ module.exports = function(grunt) {
|
||||
|
||||
grunt.loadTasks('lib/grunt');
|
||||
|
||||
var NG_VERSION = util.getVersion();
|
||||
var NG_VERSION = versionInfo.currentVersion;
|
||||
NG_VERSION.cdn = versionInfo.currentPackage.cdnVersion;
|
||||
var dist = 'angular-'+ NG_VERSION.full;
|
||||
|
||||
|
||||
//global beforeEach
|
||||
util.init();
|
||||
|
||||
|
||||
+3
-3
@@ -61,9 +61,9 @@ This process based on the idea of minimizing user pain
|
||||
1. Label `origin: google` for issues from Google
|
||||
|
||||
1. Assign a milestone:
|
||||
* Current 1.x.y milestone - regressions and urgent bugs only
|
||||
* Backlog - fixes; changes that should go into a patch release
|
||||
* Ice Box - new features; changes that belong inß a major/minor release
|
||||
* Backlog - triaged fixes and features, should be the default choice
|
||||
* Current 1.x.y milestone (e.g. 1.3.0-beta-2) - regressions and urgent bugs only
|
||||
|
||||
|
||||
1. Unassign yourself from the issue
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/local/bin/node
|
||||
#!/usr/bin/env node
|
||||
|
||||
var util = require('util');
|
||||
var cp = require('child_process');
|
||||
@@ -121,9 +121,12 @@ then(function (tags) {
|
||||
value();
|
||||
}).
|
||||
then(function (tags) {
|
||||
var master = tags.pop();
|
||||
var stable = tags.pop();
|
||||
|
||||
return [
|
||||
{ name: 'v1.0.x', tag: tags[0] },
|
||||
{ name: 'master', tag: tags[1] }
|
||||
{ name: stable.replace(/\d+$/, 'x'), tag: stable },
|
||||
{ name: 'master', tag: master}
|
||||
];
|
||||
}).
|
||||
then(allInSeries(function (branch) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<h1>Oops!</h1>
|
||||
|
||||
<p>The page you requested does not exist. Perhaps you were looking for something else...</p>
|
||||
|
||||
<div ng-controller="Error404SearchCtrl">
|
||||
|
||||
<dl ng-repeat="(key, value) in results" ng-show="value.length" style="float: left; margin-right:20px">
|
||||
<dt>{{ key }}</dt>
|
||||
<dd ng-repeat="item in value"><a ng-href="{{ item.path }}">{{ item.name }}</a></dd>
|
||||
</dl>
|
||||
</div>
|
||||
@@ -184,10 +184,12 @@ h1,h2,h3,h4,h5,h6 {
|
||||
}
|
||||
|
||||
pre {
|
||||
padding:15px;
|
||||
border:1px solid #ddd;
|
||||
display:block;
|
||||
border-radius:5px;
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.aside-nav a,
|
||||
@@ -464,6 +466,10 @@ iframe.example {
|
||||
background:rgb(189, 63, 66);
|
||||
}
|
||||
|
||||
.type-hint-regexp {
|
||||
background: rgb(90, 84, 189);
|
||||
}
|
||||
|
||||
.runnable-example-frame {
|
||||
width:100%;
|
||||
height:300px;
|
||||
@@ -501,10 +507,6 @@ h4 {
|
||||
padding-top:20px;
|
||||
}
|
||||
|
||||
.improve-docs {
|
||||
float:right;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color:#428bca;
|
||||
position: relative;
|
||||
@@ -538,10 +540,17 @@ h4 {
|
||||
background:white!important;
|
||||
}
|
||||
|
||||
.view-source, .improve-docs {
|
||||
position:relative;
|
||||
z-index:100;
|
||||
}
|
||||
|
||||
.view-source {
|
||||
margin-right:10px;
|
||||
padding-right:10px;
|
||||
border-right:1px solid #999;
|
||||
}
|
||||
|
||||
.improve-docs {
|
||||
float:right;
|
||||
}
|
||||
|
||||
.return-arguments,
|
||||
|
||||
@@ -2,6 +2,8 @@ angular.module('DocsController', [])
|
||||
|
||||
.controller('DocsController', function($scope, $rootScope, $location, $window, $cookies, NG_PAGES, NG_NAVIGATION, NG_VERSION) {
|
||||
|
||||
$scope.docsVersion = NG_VERSION.isSnapshot ? 'snapshot' : NG_VERSION.version;
|
||||
|
||||
$scope.fold = function(url) {
|
||||
if(url) {
|
||||
$scope.docs_fold = '/notes/' + url;
|
||||
@@ -87,7 +89,7 @@ angular.module('DocsController', [])
|
||||
breadcrumbPath += '/';
|
||||
});
|
||||
} else {
|
||||
$scope.currentArea = null;
|
||||
$scope.currentArea = NG_NAVIGATION['api'];
|
||||
$scope.breadcrumb = [];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -45,6 +45,10 @@ angular.module('search', [])
|
||||
};
|
||||
}])
|
||||
|
||||
.controller('Error404SearchCtrl', ['$scope', '$location', 'docsSearch', function($scope, $location, docsSearch) {
|
||||
$scope.results = docsSearch($location.path().split(/[\/\.:]/).pop());
|
||||
}])
|
||||
|
||||
.factory('lunrSearch', function() {
|
||||
return function(properties) {
|
||||
if (window.RUNNING_IN_NG_TEST_RUNNER) return null;
|
||||
|
||||
@@ -21,10 +21,10 @@ angular.module('tutorials', [])
|
||||
element.addClass('btn-group');
|
||||
element.addClass('tutorial-nav');
|
||||
element.append(templateMerge(
|
||||
'<a href="tutorial/{{prev}}"><li class="btn btn-primary"><i class="icon-step-backward"></i> Previous</li></a>\n' +
|
||||
'<a href="http://angular.github.com/angular-phonecat/step-{{seq}}/app"><li class="btn btn-primary"><i class="icon-play"></i> Live Demo</li></a>\n' +
|
||||
'<a href="https://github.com/angular/angular-phonecat/compare/step-{{diffLo}}...step-{{diffHi}}"><li class="btn btn-primary"><i class="icon-search"></i> Code Diff</li></a>\n' +
|
||||
'<a href="tutorial/{{next}}"><li class="btn btn-primary">Next <i class="icon-step-forward"></i></li></a>', props));
|
||||
'<a href="tutorial/{{prev}}"><li class="btn btn-primary"><i class="glyphicon glyphicon-step-backward"></i> Previous</li></a>\n' +
|
||||
'<a href="http://angular.github.com/angular-phonecat/step-{{seq}}/app"><li class="btn btn-primary"><i class="glyphicon glyphicon-play"></i> Live Demo</li></a>\n' +
|
||||
'<a href="https://github.com/angular/angular-phonecat/compare/step-{{diffLo}}...step-{{diffHi}}"><li class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> Code Diff</li></a>\n' +
|
||||
'<a href="tutorial/{{next}}"><li class="btn btn-primary">Next <i class="glyphicon glyphicon-step-forward"></i></li></a>', props));
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
@@ -25,6 +25,10 @@ module.exports = function(config) {
|
||||
require('./tag-defs/tutorial-step')
|
||||
]);
|
||||
|
||||
config.append('processing.inlineTagDefinitions', [
|
||||
require('./inline-tag-defs/type')
|
||||
]);
|
||||
|
||||
config.set('processing.search.ignoreWordsFile', path.resolve(packagePath, 'ignore.words'));
|
||||
|
||||
config.prepend('rendering.templateFolders', [
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
var typeClassFilter = require('dgeni-packages/ngdoc/rendering/filters/type-class');
|
||||
var encoder = new require('node-html-encoder').Encoder();
|
||||
|
||||
module.exports = {
|
||||
name: 'type',
|
||||
description: 'Replace with markup that displays a nice type',
|
||||
handlerFactory: function() {
|
||||
return function(doc, tagName, tagDescription) {
|
||||
return '<a href="" class="' + typeClassFilter.process(tagDescription) + '">'+encoder.htmlEncode(tagDescription) + '</a>';
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -22,6 +22,12 @@ module.exports = {
|
||||
_.forEach(docs, function(doc) {
|
||||
if ( doc.docType === 'error' ) {
|
||||
|
||||
// Parse out the error info from the id
|
||||
parts = doc.name.split(':');
|
||||
doc.namespace = parts[0];
|
||||
doc.name = parts[1];
|
||||
|
||||
|
||||
var namespaceDoc = errorNamespaces[doc.namespace];
|
||||
if ( !namespaceDoc ) {
|
||||
// First time we came across this namespace, so create a new one
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var gruntUtils = require('../../../lib/grunt/utils');
|
||||
var versionInfo = require('../../../lib/versions/version-info');
|
||||
|
||||
module.exports = {
|
||||
name: 'git-data',
|
||||
@@ -6,9 +7,9 @@ module.exports = {
|
||||
description: 'This processor adds information from the local git repository to the extraData injectable',
|
||||
init: function(config, injectables) {
|
||||
injectables.value('gitData', {
|
||||
version: gruntUtils.getVersion(),
|
||||
versions: gruntUtils.getPreviousVersions(),
|
||||
info: gruntUtils.getGitRepoInfo()
|
||||
version: versionInfo.currentVersion,
|
||||
versions: versionInfo.previousVersions,
|
||||
info: versionInfo.gitRepoInfo
|
||||
});
|
||||
},
|
||||
process: function(extraData, gitData) {
|
||||
|
||||
@@ -11,17 +11,17 @@ var AREA_NAMES = {
|
||||
};
|
||||
|
||||
function getNavGroup(pages, area, pageSorter, pageMapper) {
|
||||
|
||||
|
||||
var navItems = _(pages)
|
||||
// We don't want the child to include the index page as this is already catered for
|
||||
.omit(function(page) { return page.id === 'index'; })
|
||||
|
||||
|
||||
// Apply the supplied sorting function
|
||||
.sortBy(pageSorter)
|
||||
|
||||
|
||||
// Apply the supplied mapping function
|
||||
.map(pageMapper)
|
||||
|
||||
|
||||
.value();
|
||||
|
||||
return {
|
||||
@@ -145,6 +145,9 @@ module.exports = {
|
||||
_(docs)
|
||||
.filter(function(doc) { return doc.area === 'api'; })
|
||||
.filter(function(doc) { return doc.docType === 'module'; })
|
||||
.forEach(function(doc) { if ( !doc.path ) {
|
||||
log.warn('Missing path property for ', doc.id);
|
||||
}})
|
||||
.map(function(doc) { return _.pick(doc, ['id', 'module', 'docType', 'area']); })
|
||||
.tap(function(docs) {
|
||||
log.debug(docs);
|
||||
@@ -173,7 +176,7 @@ module.exports = {
|
||||
// - ngView
|
||||
// - section "service"
|
||||
// - $route
|
||||
//
|
||||
//
|
||||
var areas = {};
|
||||
_(navPages)
|
||||
.groupBy('area')
|
||||
@@ -188,12 +191,6 @@ module.exports = {
|
||||
area.navGroups = navGroupMapper(pages, area);
|
||||
});
|
||||
|
||||
_.forEach(docs, function(doc) {
|
||||
if ( !doc.path ) {
|
||||
log.warn('Missing path property for ', doc.id);
|
||||
}
|
||||
});
|
||||
|
||||
// Extract a list of basic page information for mapping paths to paritals and for client side searching
|
||||
var pages = _(docs)
|
||||
.map(function(doc) {
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
<div class="container main-grid main-header-grid">
|
||||
<div class="grid-left">
|
||||
<div ng-controller="DocsVersionsCtrl" class="picker version-picker">
|
||||
<select ng-options="v as ('v' + v.full) group by (v.isStable?'Stable':'Unstable') for v in docs_versions"
|
||||
<select ng-options="v as ('v' + v.version + (v.isSnapshot ? ' (snapshot)' : '')) group by (v.isStable?'Stable':'Unstable') for v in docs_versions"
|
||||
ng-model="docs_version"
|
||||
ng-change="jumpToDocsVersion(docs_version)"
|
||||
class="docs-version-jump">
|
||||
@@ -219,7 +219,7 @@
|
||||
</div>
|
||||
<div class="grid-right">
|
||||
<div id="loading" ng-show="loading">Loading...</div>
|
||||
<div ng-hide="loading" ng-include="currentPage.outputPath" onload="afterPartialLoaded()" autoscroll></div>
|
||||
<div ng-hide="loading" ng-include="currentPage.outputPath || 'Error404.html'" onload="afterPartialLoaded()" autoscroll></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
{# Be aware that we need these extra new lines here or marked will not realise that the <div>
|
||||
is HTML and wrap each line in a <p> - thus breaking the HTML #}
|
||||
|
||||
<div>
|
||||
<a ng-href="http://plnkr.co/edit/ngdoc:{$ doc.example.id $}@{{docsVersion}}?p=preview" class="btn pull-right" target="_blank">
|
||||
<i class="glyphicon glyphicon-edit"> </i>
|
||||
Edit in Plunker</a>
|
||||
<div class="runnable-example"
|
||||
path="{$ doc.example.outputFolder $}"
|
||||
{%- for attrName, attrValue in doc.example.attributes %}
|
||||
{$ attrName $}="{$ attrValue $}"{% endfor %}>
|
||||
|
||||
{% for fileName, file in doc.example.files %}
|
||||
<div class="runnable-example-file" {% for attrName, attrValue in file.attributes %}
|
||||
{$ attrName $}="{$ attrValue $}"{% endfor %}>
|
||||
{% code -%}
|
||||
{$ file.fileContents $}
|
||||
{%- endcode %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<iframe class="runnable-example-frame" src="{$ doc.example.outputFolder $}/index.html" name="{$ doc.example.id $}"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Be aware that we need these extra new lines here or marked will not realise that the <div>
|
||||
above is HTML and wrap each line in a <p> - thus breaking the HTML #}
|
||||
@@ -30,6 +30,9 @@ Following are invalid uses of this directive:
|
||||
|
||||
<!-- ERROR because `myFn()=localValue` is an invalid statement -->
|
||||
<my-directive bind="myFn()">
|
||||
|
||||
<!-- ERROR because attribute bind wasn't provided -->
|
||||
<my-directive>
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ You can also get this error if you accidentally load AngularJS itself more than
|
||||
<html ng-app>
|
||||
<head>
|
||||
<script src="angular.js"></script>
|
||||
|
||||
|
||||
...
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
...
|
||||
|
||||
<script src="angular.js"></script>
|
||||
|
||||
@@ -325,7 +325,7 @@ This will not render properly, unless we do some scope magic.
|
||||
|
||||
The first issue we have to solve is that the dialog box template expects `title` to be defined.
|
||||
But we would like the template's scope property `title` to be the result of interpolating the
|
||||
`<dialog>` element's `title` attribute (i.e. `"Hello {{username}}"`. Furthermore, the buttons expect
|
||||
`<dialog>` element's `title` attribute (i.e. `"Hello {{username}}"`). Furthermore, the buttons expect
|
||||
the `onOk` and `onCancel` functions to be present in the scope. This limits the usefulness of the
|
||||
widget. To solve the mapping issue we use the `locals` to create local variables which the template
|
||||
expects as follows:
|
||||
|
||||
@@ -32,9 +32,9 @@ In the following example we will build a form to calculate the costs of an invoi
|
||||
Let's start with input fields for quantity and cost whose values are multiplied to produce the total of the invoice:
|
||||
|
||||
|
||||
<example>
|
||||
<example name="guide-concepts-1" ng-app-included="true">
|
||||
<file name="index.html">
|
||||
<div ng-init="qty=1;cost=2">
|
||||
<div ng-app ng-init="qty=1;cost=2">
|
||||
<b>Invoice:</b>
|
||||
<div>
|
||||
Quantity: <input type="number" ng-model="qty" required >
|
||||
@@ -102,7 +102,7 @@ The concept behind this is <a name="databinding">"{@link databinding two-way dat
|
||||
Let's add some more logic to the example that allows us to enter and calculate the costs in
|
||||
different currencies and also pay the invoice.
|
||||
|
||||
<example module="invoice1">
|
||||
<example name="guide-concepts-2" ng-app-included="true" >
|
||||
<file name="invoice1.js">
|
||||
angular.module('invoice1', [])
|
||||
.controller('InvoiceController', function() {
|
||||
@@ -128,7 +128,7 @@ different currencies and also pay the invoice.
|
||||
});
|
||||
</file>
|
||||
<file name="index.html">
|
||||
<div ng-controller="InvoiceController as invoice">
|
||||
<div ng-app="invoice1" ng-controller="InvoiceController as invoice">
|
||||
<b>Invoice:</b>
|
||||
<div>
|
||||
Quantity: <input type="number" ng-model="invoice.qty" required >
|
||||
@@ -191,7 +191,7 @@ from the web, e.g. by calling the Yahoo Finance API, without changing the contro
|
||||
|
||||
Let's refactor our example and move the currency conversion into a service in another file:
|
||||
|
||||
<example module="invoice2">
|
||||
<example name="guide-concepts-2" ng-app-included="true">
|
||||
<file name="finance2.js">
|
||||
angular.module('finance2', [])
|
||||
.factory('currencyConverter', function() {
|
||||
@@ -228,7 +228,7 @@ Let's refactor our example and move the currency conversion into a service in an
|
||||
}]);
|
||||
</file>
|
||||
<file name="index.html">
|
||||
<div ng-controller="InvoiceController as invoice">
|
||||
<div ng-app="invoice2" ng-controller="InvoiceController as invoice">
|
||||
<b>Invoice:</b>
|
||||
<div>
|
||||
Quantity: <input type="number" ng-model="invoice.qty" required >
|
||||
@@ -302,7 +302,7 @@ to something shorter like `a`.
|
||||
Let's finish our example by fetching the exchange rates from the Yahoo Finance API.
|
||||
The following example shows how this is done with Angular:
|
||||
|
||||
<example module="invoice3">
|
||||
<example name="guide-concepts-3" ng-app-included="true">
|
||||
<file name="invoice3.js">
|
||||
angular.module('invoice3', ['finance3'])
|
||||
.controller('InvoiceController', ['currencyConverter', function(currencyConverter) {
|
||||
@@ -356,7 +356,7 @@ The following example shows how this is done with Angular:
|
||||
}]);
|
||||
</file>
|
||||
<file name="index.html">
|
||||
<div ng-controller="InvoiceController as invoice">
|
||||
<div ng-app="invoice3" ng-controller="InvoiceController as invoice">
|
||||
<b>Invoice:</b>
|
||||
<div>
|
||||
Quantity: <input type="number" ng-model="invoice.qty" required >
|
||||
|
||||
@@ -293,9 +293,9 @@ The `restrict` option is typically set to:
|
||||
* `'E'` - only matches element name
|
||||
* `'C'` - only matches class name
|
||||
|
||||
These restictions can all be combined as needed:
|
||||
These restrictions can all be combined as needed:
|
||||
|
||||
* `'AEC'` - matches either attribure or element or class name
|
||||
* `'AEC'` - matches either attribute or element or class name
|
||||
|
||||
Let's change our directive to use `restrict: 'E'`:
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ Note that `novalidate` is used to disable browser's native form validation.
|
||||
|
||||
# Using CSS classes
|
||||
|
||||
To allow styling of form as well as controls, `ngModel` add these CSS classes:
|
||||
To allow styling of form as well as controls, `ngModel` adds these CSS classes:
|
||||
|
||||
- `ng-valid`
|
||||
- `ng-invalid`
|
||||
@@ -211,26 +211,24 @@ In the following example we create two directives.
|
||||
|
||||
<example module="form-example1">
|
||||
<file name="index.html">
|
||||
<div ng-controller="Controller">
|
||||
<form name="form" class="css-form" novalidate>
|
||||
<div>
|
||||
Size (integer 0 - 10):
|
||||
<input type="number" ng-model="size" name="size"
|
||||
min="0" max="10" integer />{{size}}<br />
|
||||
<span ng-show="form.size.$error.integer">This is not valid integer!</span>
|
||||
<span ng-show="form.size.$error.min || form.size.$error.max">
|
||||
The value must be in range 0 to 10!</span>
|
||||
</div>
|
||||
<form name="form" class="css-form" novalidate>
|
||||
<div>
|
||||
Size (integer 0 - 10):
|
||||
<input type="number" ng-model="size" name="size"
|
||||
min="0" max="10" integer />{{size}}<br />
|
||||
<span ng-show="form.size.$error.integer">This is not valid integer!</span>
|
||||
<span ng-show="form.size.$error.min || form.size.$error.max">
|
||||
The value must be in range 0 to 10!</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
Length (float):
|
||||
<input type="text" ng-model="length" name="length" smart-float />
|
||||
{{length}}<br />
|
||||
<span ng-show="form.length.$error.float">
|
||||
This is not a valid float number!</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
Length (float):
|
||||
<input type="text" ng-model="length" name="length" smart-float />
|
||||
{{length}}<br />
|
||||
<span ng-show="form.length.$error.float">
|
||||
This is not a valid float number!</span>
|
||||
</div>
|
||||
</form>
|
||||
</file>
|
||||
|
||||
<file name="script.js">
|
||||
|
||||
@@ -26,7 +26,7 @@ To make your Angular application work on IE please make sure that:
|
||||
1. You polyfill JSON.stringify for IE7 and below. You can use
|
||||
[JSON2](https://github.com/douglascrockford/JSON-js) or
|
||||
[JSON3](http://bestiejs.github.com/json3/) polyfills for this.
|
||||
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html xmlns:ng="http://angularjs.org">
|
||||
@@ -42,7 +42,7 @@ To make your Angular application work on IE please make sure that:
|
||||
```
|
||||
|
||||
2. add `id="ng-app"` to the root element in conjunction with `ng-app` attribute
|
||||
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="optionalModuleName">
|
||||
@@ -54,7 +54,7 @@ To make your Angular application work on IE please make sure that:
|
||||
`<div ng-view>` instead), or
|
||||
|
||||
4. if you **do use** custom element tags, then you must take these steps to make IE 8 and below happy:
|
||||
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="optionalModuleName">
|
||||
@@ -64,7 +64,7 @@ To make your Angular application work on IE please make sure that:
|
||||
document.createElement('ng-include');
|
||||
document.createElement('ng-pluralize');
|
||||
document.createElement('ng-view');
|
||||
|
||||
|
||||
// Optionally these for CSS
|
||||
document.createElement('ng:include');
|
||||
document.createElement('ng:pluralize');
|
||||
@@ -79,7 +79,7 @@ To make your Angular application work on IE please make sure that:
|
||||
```
|
||||
5. Use `ng-style` tags instead of `style="{{ someCss }}"`. The later works in Chrome and Firefox
|
||||
but does not work in Internet Explorer <= 11 (the most recent version at time of writing).
|
||||
|
||||
|
||||
|
||||
The **important** parts are:
|
||||
|
||||
@@ -165,7 +165,7 @@ In IE, the behavior is that the `BODY` element has three children:
|
||||
|
||||
## CSS Styling of Custom Tag Names
|
||||
|
||||
To make CSS selectors work with custom elements, the custom element name must be pre-created with
|
||||
To make CSS selectors work with custom elements, the custom element name must be pre-created with
|
||||
`document.createElement('my-tag')` regardless of XML namespace.
|
||||
|
||||
```html
|
||||
|
||||
@@ -7,7 +7,7 @@ AngularJS version 1.2 introduces several breaking changes that may require chang
|
||||
application's source code.
|
||||
|
||||
Although we try to avoid breaking changes, there are some cases where it is unavoidable.
|
||||
AngularJS 1.2 has undergone a thourough security review to make applications safer by default,
|
||||
AngularJS 1.2 has undergone a thorough security review to make applications safer by default,
|
||||
which has driven many of these changes. Several new features, especially animations, would not
|
||||
be possible without a few changes. Finally, some outstanding bugs were best fixed by changing
|
||||
an existing API.
|
||||
@@ -43,11 +43,12 @@ below should still apply, but you may want to consult the
|
||||
<li>{@link guide/migration#ngscenario ngScenario}</li>
|
||||
<li>{@link guide/migration#nginclude-and-ngview-replace-its-entire-element-on-update ngInclude and ngView replace its entire element on update}</li>
|
||||
<li>{@link guide/migration#urls-are-now-sanitized-against-a-whitelist URLs are now sanitized against a whitelist}</li>
|
||||
<li>{@link guide/migration#isolate-scope-only-exposed-to-directives-with-property Isolate scope only exposed to directives with <code>scope</code> property}</li>
|
||||
<li>{@link guide/migration#isolate-scope-only-exposed-to-directives-with-scope-property Isolate scope only exposed to directives with <code>scope</code> property}</li>
|
||||
<li>{@link guide/migration#change-to-interpolation-priority Change to interpolation priority}</li>
|
||||
<li>{@link guide/migration#underscore-prefixed/suffixed-properties-are-non-bindable Underscore-prefixed/suffixed properties are non-bindable}</li>
|
||||
<li>{@link guide/migration#you-cannot-bind-to-select[multiple] You cannot bind to select[multiple]}</li>
|
||||
<li>{@link guide/migration#uncommon-region-specific-local-files-were-removed-from-i18n Uncommon region-specific local files were removed from i18n}</li>
|
||||
<li>{@link guide/migration#services-can-now-return-functions Services can now return functions}</li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -493,7 +494,7 @@ See [31f190d4](https://github.com/angular/angular.js/commit/31f190d4d53921d32253
|
||||
|
||||
the priority of ngRepeat, ngSwitchWhen, ngIf, ngInclude and ngView has changed. This could affect directives that explicitly specify their priority.
|
||||
|
||||
In order to make ngRepeat, ngSwitchWhen, ngIf, ngInclude and ngView work together in all common scenarios their directives are being adjusted to achieve the following precendence:
|
||||
In order to make ngRepeat, ngSwitchWhen, ngIf, ngInclude and ngView work together in all common scenarios their directives are being adjusted to achieve the following precedence:
|
||||
|
||||
|
||||
Directive | Old Priority | New Priority
|
||||
@@ -532,7 +533,7 @@ See [7d69d52a](https://github.com/angular/angular.js/commit/7d69d52acff8578e0f7d
|
||||
|
||||
A whitelist configured via `$compileProvider` can be used to configure what URLs are considered safe.
|
||||
By default all common protocol prefixes are whitelisted including `data:` URIs with mime types `image/*`.
|
||||
This change sholdn't impact apps that don't contain malicious image links.
|
||||
This change shouldn't impact apps that don't contain malicious image links.
|
||||
|
||||
See [1adf29af](https://github.com/angular/angular.js/commit/1adf29af13890d61286840177607edd552a9df97),
|
||||
[3e39ac7e](https://github.com/angular/angular.js/commit/3e39ac7e1b10d4812a44dad2f959a93361cd823b).
|
||||
@@ -613,7 +614,7 @@ controller.) That's easier said that done for two reasons:
|
||||
someone on the scope chain for JavaScript use, you also expose it to
|
||||
Angular expressions
|
||||
2. The new `controller as` syntax that's now in increased usage exposes the
|
||||
entire controller on the scope chain greatly increaing the exposed surface.
|
||||
entire controller on the scope chain greatly increasing the exposed surface.
|
||||
|
||||
Though Angular expressions are written and controlled by the developer, they:
|
||||
|
||||
@@ -653,3 +654,39 @@ load and use your copy of the locale file provided that you maintain it yourself
|
||||
|
||||
See [6382e21f](https://github.com/angular/angular.js/commit/6382e21fb28541a2484ac1a241d41cf9fbbe9d2c).
|
||||
|
||||
## Services can now return functions
|
||||
|
||||
Previously, the service constructor only returned objects regardless of whether a function was returned.
|
||||
|
||||
Now, `$injector.instantiate` (and thus `$provide.service`) behaves the same as the native
|
||||
`new` operator and allows functions to be returned as a service.
|
||||
|
||||
If using a JavaScript preprocessor it's quite possible when upgrading that services could start behaving incorrectly.
|
||||
Make sure your services return the correct type wanted.
|
||||
|
||||
**Coffeescript example**
|
||||
|
||||
```
|
||||
myApp.service 'applicationSrvc', ->
|
||||
@something = "value"
|
||||
@someFunct = ->
|
||||
"something else"
|
||||
```
|
||||
|
||||
pre 1.2 this service would return the whole object as the service.
|
||||
|
||||
post 1.2 this service returns `someFunct` as the value of the service
|
||||
|
||||
you would need to change this services to
|
||||
|
||||
```
|
||||
myApp.service 'applicationSrvc', ->
|
||||
@something = "value"
|
||||
@someFunct = ->
|
||||
"something else"
|
||||
return
|
||||
```
|
||||
|
||||
to continue to return the complete instance.
|
||||
|
||||
See [c22adbf1](https://github.com/angular/angular.js/commit/c22adbf160f32c1839fbb35382b7a8c6bcec2927).
|
||||
|
||||
@@ -66,8 +66,9 @@ that you break your application to multiple modules like this:
|
||||
* And an application level module which depends on the above modules and contains any
|
||||
initialization code.
|
||||
|
||||
We've also written a document on how we organize large apps at Google and on how to write
|
||||
reusable components.
|
||||
We've also
|
||||
[written a document](http://blog.angularjs.org/2014/02/an-angularjs-style-guide-and-best.html)
|
||||
on how we organize large apps at Google.
|
||||
|
||||
The above is a suggestion. Tailor it to your needs.
|
||||
|
||||
@@ -172,7 +173,7 @@ angular.module('myModule', []).
|
||||
|
||||
<div class="alert alert-info">
|
||||
When bootstrapping, first Angular applies all constant definitions.
|
||||
Then Angular applies configuration blocks in the order same order they were registered.
|
||||
Then Angular applies configuration blocks in the same order they were registered.
|
||||
</div>
|
||||
|
||||
## Run Blocks
|
||||
|
||||
@@ -143,7 +143,7 @@ primitive, object literal, function, or even an instance of a custom type.
|
||||
## Service Recipe
|
||||
|
||||
JavaScript developers often use custom types to write object-oriented code. Let's explore how we
|
||||
could launch a unicorn into the space via our `unicornLauncher` service that is an instance of
|
||||
could launch a unicorn into space via our `unicornLauncher` service that is an instance of
|
||||
custom type:
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -11,15 +11,15 @@ Angular services are:
|
||||
|
||||
* Lazily instantiated – Angular only instantiates a service when an application component depends
|
||||
on it.
|
||||
* Singletons – Each component is dependent on a service gets a reference to the single instance
|
||||
* Singletons – Each component dependent on a service gets a reference to the single instance
|
||||
generated by the service factory.
|
||||
|
||||
Angular offers several useful services (like {@link ng.$http `$http`}) but for most applications
|
||||
Angular offers several useful services (like {@link ng.$http `$http`}), but for most applications
|
||||
you'll also want to {@link services#creating-services create your own}.
|
||||
|
||||
<div class="alert alert-info">
|
||||
**Note:** Like other core Angular identifiers built-in services always start with `$`
|
||||
(i.e. `$http`).
|
||||
(e.g. `$http`).
|
||||
</div>
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ injection of `$window`, `$scope`, and our `notify` service:
|
||||
</file>
|
||||
</example>
|
||||
|
||||
<div class="alert alert-error">
|
||||
<div class="alert alert-danger">
|
||||
**Careful:** If you plan to [minify](http://en.wikipedia.org/wiki/Minification_(programming) your code,
|
||||
your variable names will get renamed unless you use one of the annotation techniques above.
|
||||
</div>
|
||||
@@ -215,8 +215,8 @@ In the example, note that:
|
||||
{@link ng.$log `$log`} services.
|
||||
* The `routeTemplateMonitor` service depends on the built-in {@link ngRoute.$route `$route`}
|
||||
service and our custom `batchLog` service.
|
||||
* Both services use the and array notation to declare their dependencies.
|
||||
* That the order of identifiers in the array is the same as the order of argument
|
||||
* Both services use the array notation to declare their dependencies.
|
||||
* The order of identifiers in the array is the same as the order of argument
|
||||
names in the factory function.
|
||||
|
||||
### Registering a Service with `$provide`
|
||||
@@ -234,7 +234,7 @@ angular.module('myModule', []).config(function($provide) {
|
||||
});
|
||||
```
|
||||
|
||||
This is technique is often used in unit tests to mock out a service's dependencies.
|
||||
This technique is often used in unit tests to mock out a service's dependencies.
|
||||
|
||||
|
||||
## Unit Testing
|
||||
|
||||
@@ -258,7 +258,7 @@ expect($scope.strength).toEqual('weak');
|
||||
```
|
||||
|
||||
Notice that the test is not only much shorter, it is also easier to follow what is happening. We say
|
||||
that such a test tells a story, rather then asserting random bits which don't seem to be related.
|
||||
that such a test tells a story, rather than asserting random bits which don't seem to be related.
|
||||
|
||||
## Filters
|
||||
{@link ng.$filterProvider Filters} are functions which transform the data into a user readable
|
||||
|
||||
@@ -11,12 +11,12 @@ See the [contributing guidelines](https://github.com/angular/angular.js/blob/mas
|
||||
for how to contribute your own code to AngularJS.
|
||||
|
||||
|
||||
1. {@link #building-and-testing-angularjs_installing-dependencies Installing Dependencies}
|
||||
2. {@link #building-and-testing-angularjs_forking-angular-on-github Forking Angular on Github}
|
||||
3. {@link #building-and-testing-angularjs_building-angularjs Building AngularJS}
|
||||
4. {@link #building-and-testing-angularjs_running-a-local-development-web-server Running a Local Development Web Server}
|
||||
5. {@link #building-and-testing-angularjs_running-the-unit-test-suite Running the Unit Test Suite}
|
||||
6. {@link #building-and-testing-angularjs_running-the-end-to-end-test-suite Running the End-to-end Test Suite}
|
||||
1. {@link misc/contribute#installing-dependencies Installing Dependencies}
|
||||
2. {@link misc/contribute#forking-angular-on-github Forking Angular on Github}
|
||||
3. {@link misc/contribute#building-angularjs Building AngularJS}
|
||||
4. {@link misc/contribute#running-a-local-development-web-server Running a Local Development Web Server}
|
||||
5. {@link misc/contribute#running-the-unit-test-suite Running the Unit Test Suite}
|
||||
6. {@link misc/contribute#running-the-end-to-end-test-suite Running the End-to-end Test Suite}
|
||||
|
||||
## Installing Dependencies
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ the construction of an AngularJS web app. The app you will build is a catalog th
|
||||
of Android devices, lets you filter the list to see only devices that interest you, and then view
|
||||
details for any device.
|
||||
|
||||
<img class="diagram" src="img/tutorial/catalog_screen.png" width="488" height="413">
|
||||
<img class="diagram" src="img/tutorial/catalog_screen.png" width="488" height="413" alt="demo
|
||||
application running in the browser">
|
||||
|
||||
Work through the tutorial to see how Angular makes browsers smarter — without the use of extensions
|
||||
or plug-ins. As you work through the tutorial, you will:
|
||||
@@ -57,63 +58,71 @@ and follow the instructions for setting up your computer.
|
||||
<div class="tab-pane well" id="git-mac" title="Git on Mac/Linux">
|
||||
<ol>
|
||||
<li><p>You'll need Git, which you can get from
|
||||
<a href="http://git-scm.com/download">the Git site</a>.</p></li>
|
||||
<a href="http://git-scm.com/download" title="Git site download">the Git site</a>.</p></li>
|
||||
<li><p>Clone the angular-phonecat repository located at
|
||||
<a href="https://github.com/angular/angular-phonecat">Github</a> by running the following command:</p>
|
||||
<a href="https://github.com/angular/angular-phonecat" title="Github Phonecat Repo">Github</a> by
|
||||
running the following command:</p>
|
||||
<pre>git clone https://github.com/angular/angular-phonecat.git</pre>
|
||||
<p>This command creates the <code>angular-phonecat</code> directory in your current
|
||||
directory.</p></li>
|
||||
<p>This command creates the <code>angular-phonecat</code> directory in your current directory.</p></li>
|
||||
<li><p>Change your current directory to <code>angular-phonecat</code>:</p>
|
||||
<pre>cd angular-phonecat</pre>
|
||||
<p>The tutorial instructions, from now on, assume you are running all commands from the <code>angular-phonecat</code>
|
||||
directory.</p></li>
|
||||
<p>The tutorial instructions, from now on, assume you are running all commands from the
|
||||
<code>angular-phonecat</code> directory.</p></li>
|
||||
<li><p>You will also need Node.js and Karma to run unit tests, so please verify that you have
|
||||
<a href="http://nodejs.org/">Node.js</a> v0.10 or better installed
|
||||
<a href="http://nodejs.org/" title="NodeJS org">Node.js</a> v0.10 or better installed
|
||||
and that the <code>node</code> executable is on your <code>PATH</code> by running the following
|
||||
command in a terminal window:</p></li>
|
||||
<pre>node --version</pre>
|
||||
<p>Additionally install <a href="http://karma-runner.github.io/">Karma</a> and its plugins if you
|
||||
don't have it already:</p>
|
||||
<div class="alert alert-info">**Helpful note:** If you need to run a different version of
|
||||
node.js in your local environment, consider installing
|
||||
<a href="https://github.com/creationix/nvm" title="Node Version Manager Github Repo link">
|
||||
Node Version Manager (nvm)</a>.</div>
|
||||
<p>Additionally install <a href="http://karma-runner.github.io/" title="Karma site">Karma</a> and
|
||||
its plugins if you don't have it already:</p>
|
||||
<pre>
|
||||
npm install
|
||||
</pre></li>
|
||||
<li><p>You will need an http server running on your system. Mac and Linux machines typically
|
||||
have Apache pre-installed, but If you don't already have one installed, you can use <code>node</code>
|
||||
to run a simple bundled http server: <code>node scripts/web-server.js</code>.</p></li>
|
||||
have Apache pre-installed, but If you don't already have one installed, you can use <code>node</code>
|
||||
to run <code>scripts/web-server.js</code>, a simple bundled http server.</p></li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane well" id="git-win" title="Git on Windows">
|
||||
<ol>
|
||||
<li><p>You will need Node.js and Karma to run unit tests, so please verify that you have
|
||||
<a href="http://nodejs.org/">Node.js</a> v0.10 or better installed
|
||||
<a href="http://nodejs.org/" title="NodeJS site">Node.js</a> v0.10 or better installed
|
||||
and that the <code>node</code> executable is on your <code>PATH</code> by running the following
|
||||
command in a terminal window:</p>
|
||||
<pre>node --version</pre>
|
||||
<p>Additionally install <a href="http://karma-runner.github.io/">Karma</a> if you
|
||||
don't have it already:</p>
|
||||
<div class="alert alert-info">**Helpful note:** If you need to run a different version of
|
||||
node.js in your local environment, consider installing
|
||||
<a href="https://github.com/creationix/nvm" title="Node Version Manager Github Repo link">
|
||||
Node Version Manager (nvm)</a>.</div>
|
||||
<p>Additionally install <a href="http://karma-runner.github.io/" title="Karma site">Karma</a>
|
||||
if you don't have it already:</p>
|
||||
<pre>npm install -g karma</pre>
|
||||
</li>
|
||||
<li><p>You'll also need Git, which you can get from
|
||||
<a href="http://git-scm.com/download">the Git site</a>.</p></li>
|
||||
<a href="http://git-scm.com/download" title="Git site download">the Git site</a>.</p></li>
|
||||
<li><p>Clone the angular-phonecat repository located at <a
|
||||
href="https://github.com/angular/angular-phonecat">Github</a> by running the following command:</p>
|
||||
<pre>git clone https://github.com/angular/angular-phonecat.git</pre>
|
||||
href="https://github.com/angular/angular-phonecat" "Github Angular-phonecat Repo">Github</a> by running
|
||||
the following command:</p><pre>git clone https://github.com/angular/angular-phonecat.git</pre>
|
||||
<p>This command creates the <code>angular-phonecat</code> directory in your current directory.</p></li>
|
||||
<li><p>Change your current directory to <code>angular-phonecat</code>:</p>
|
||||
<pre>cd angular-phonecat</pre>
|
||||
<p>The tutorial instructions assume you are running all commands from the <code>angular-phonecat</code>
|
||||
directory.</p>
|
||||
directory.</p>
|
||||
<p>You should run all <code>git</code> commands from Git bash.</p>
|
||||
<p>Other commands like <code>test.bat</code> or <code>e2e-test.bat</code> should be
|
||||
executed from the Windows command line.</li>
|
||||
<li><p>You need an http server running on your system, but if you don't already have one
|
||||
already installed, you can use <code>node</code> to run a simple
|
||||
bundled http server: <code>node scripts\web-server.js</code>.</p></li>
|
||||
<p>Other commands like <code>test.bat</code> or <code>e2e-test.bat</code> should be executed from the
|
||||
Windows command line.</li>
|
||||
<li><p>You need an http server running on your system, but if you don't already have one already
|
||||
installed, you can use <code>node</code> to run <code>scripts\web-server.js</code>, a simple bundled
|
||||
http server.</p></li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
The last thing to do is to make sure your computer has a web browser and a good text editor
|
||||
installed. Now, let's get some cool stuff done!
|
||||
The last thing to do is to make sure your computer has a web browser and a good text editor installed. Now,
|
||||
let's get some cool stuff done!
|
||||
|
||||
{@link step_00 <span class="btn btn-primary">Get Started!</span>}
|
||||
<a href="tutorial/step_00" title="Next Step"><span class="btn btn-primary">Get Started!</span></a>
|
||||
|
||||
@@ -183,7 +183,7 @@ is available to be injected.
|
||||
### Writing and Running Tests
|
||||
Angular developers prefer the syntax of Jasmine's Behavior-driven Development (BDD) framework when
|
||||
writing tests. Although Angular does not require you to use Jasmine, we wrote all of the tests in
|
||||
this tutorial in Jasmine. You can learn about Jasmine on the [Jasmine home page](http://pivotal.github.com/jasmine/) and at the [Jasmine docs](http://pivotal.github.io/jasmine/).
|
||||
this tutorial in Jasmine. You can learn about Jasmine on the [Jasmine home page](http://jasmine.github.io/) and at the [Jasmine docs](http://jasmine.github.io/).
|
||||
|
||||
The angular-seed project is pre-configured to run all unit tests using [Karma](http://karma-runner.github.io/). Ensure that the necessary karma plugins are installed.
|
||||
You can do this by issuing `npm install` into your terminal.
|
||||
@@ -226,6 +226,10 @@ To run the test, do the following:
|
||||
|
||||
Refresh your browser and verify that it says "Hello, World!".
|
||||
|
||||
* Update the unit test for the controler in ./tests/unit/controlersSpec.js to reflect the previous change. For example by adding:
|
||||
|
||||
expect(scope.name).toBe('World');
|
||||
|
||||
* Create a repeater that constructs a simple table:
|
||||
|
||||
<table>
|
||||
|
||||
@@ -114,7 +114,7 @@ describe('PhoneCat App', function() {
|
||||
```
|
||||
|
||||
Even though the syntax of this test looks very much like our controller unit test written with
|
||||
Jasmine, the end-to-end test uses APIs of {@link guide/dev_guide.e2e-testing Angular's end-to-end
|
||||
Jasmine, the end-to-end test uses APIs of {@link guide/e2e-testing Angular's end-to-end
|
||||
test runner}.
|
||||
|
||||
To run the end-to-end test, open one of the following in a new browser tab:
|
||||
|
||||
@@ -91,7 +91,7 @@ phonecatApp.controller('PhoneListCtrl', function ($scope) {
|
||||
record. This property is used to order phones by age.
|
||||
|
||||
* We added a line to the controller that sets the default value of `orderProp` to `age`. If we had
|
||||
not set a default value here, the `orderBy` filter would remain uninitialized until our
|
||||
not set a default value here, the `orderBy` filter would remain uninitialized until our
|
||||
user picked an option from the drop down menu.
|
||||
|
||||
This is a good time to talk about two-way data-binding. Notice that when the app is loaded in the
|
||||
@@ -117,7 +117,7 @@ describe('PhoneCat controllers', function() {
|
||||
var scope, ctrl;
|
||||
|
||||
beforeEach(module('phonecatApp'));
|
||||
|
||||
|
||||
beforeEach(inject(function($controller) {
|
||||
scope = {};
|
||||
ctrl = $controller('PhoneListCtrl', {$scope:scope});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
Enough of building an app with three phones in a hard-coded dataset! Let's fetch a larger dataset
|
||||
from our server using one of Angular's built-in {@link guide/dev_guide.services services} called {@link
|
||||
from our server using one of Angular's built-in {@link guide/services services} called {@link
|
||||
ng.$http $http}. We will use Angular's {@link guide/di dependency
|
||||
injection (DI)} to provide the service to the `PhoneListCtrl` controller.
|
||||
|
||||
@@ -20,7 +20,6 @@ You should now see a list of 20 phones.
|
||||
The most important changes are listed below. You can see the full diff on [GitHub](https://github.com/angular/angular-phonecat/compare/step-4...step-5):
|
||||
|
||||
## Data
|
||||
|
||||
The `app/phones/phones.json` file in your project is a dataset that contains a larger list of phones
|
||||
stored in the JSON format.
|
||||
|
||||
@@ -44,7 +43,7 @@ Following is a sample of the file:
|
||||
|
||||
We'll use Angular's {@link ng.$http $http} service in our controller to make an HTTP
|
||||
request to your web server to fetch the data in the `app/phones/phones.json` file. `$http` is just
|
||||
one of several built-in {@link guide/dev_guide.services angular services} that handle common operations
|
||||
one of several built-in {@link guide/services Angular services} that handle common operations
|
||||
in web apps. Angular injects these services for you where you need them.
|
||||
|
||||
Services are managed by Angular's {@link guide/di DI subsystem}. Dependency injection
|
||||
@@ -74,10 +73,10 @@ tutorial.)
|
||||
|
||||
The `$http` service returns a {@link ng.$q promise object} with a `success`
|
||||
method. We call this method to handle the asynchronous response and assign the phone data to the
|
||||
scope controlled by this controller, as a model called `phones`. Notice that angular detected the
|
||||
scope controlled by this controller, as a model called `phones`. Notice that Angular detected the
|
||||
json response and parsed it for us!
|
||||
|
||||
To use a service in angular, you simply declare the names of the dependencies you need as arguments
|
||||
To use a service in Angular, you simply declare the names of the dependencies you need as arguments
|
||||
to the controller's constructor function, as follows:
|
||||
|
||||
phonecatApp.controller('PhoneListCtrl', function ($scope, $http) {...}
|
||||
@@ -96,7 +95,7 @@ dependencies.
|
||||
### `$` Prefix Naming Convention
|
||||
|
||||
You can create your own services, and in fact we will do exactly that in step 11. As a naming
|
||||
convention, angular's built-in services, Scope methods and a few other Angular APIs have a `$`
|
||||
convention, Angular's built-in services, Scope methods and a few other Angular APIs have a `$`
|
||||
prefix in front of the name.
|
||||
|
||||
The `$` prefix is there to namespace Angular-provided services.
|
||||
@@ -167,7 +166,7 @@ __`test/unit/controllersSpec.js`:__
|
||||
Because we started using dependency injection and our controller has dependencies, constructing the
|
||||
controller in our tests is a bit more complicated. We could use the `new` operator and provide the
|
||||
constructor with some kind of fake `$http` implementation. However, the recommended (and easier) way
|
||||
is to create a controller in the test environment in the same way that angular does it in the
|
||||
is to create a controller in the test environment in the same way that Angular does it in the
|
||||
production code behind the scenes, as follows:
|
||||
|
||||
```js
|
||||
@@ -269,7 +268,7 @@ to the first 5 in the list. Use the following code in the `$http` callback:
|
||||
|
||||
# Summary
|
||||
|
||||
Now that you have learned how easy it is to use angular services (thanks to Angular's dependency
|
||||
Now that you have learned how easy it is to use Angular services (thanks to Angular's dependency
|
||||
injection), go to {@link step_06 step 6}, where you will add some
|
||||
thumbnail images of phones and some links.
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ the element attribute.
|
||||
|
||||
We also added phone images next to each record using an image tag with the {@link
|
||||
ng.directive:ngSrc ngSrc} directive. That directive prevents the
|
||||
browser from treating the angular `{{ expression }}` markup literally, and initiating a request to
|
||||
browser from treating the Angular `{{ expression }}` markup literally, and initiating a request to
|
||||
invalid url `http://localhost:8000/app/{{phone.imageUrl}}`, which it would have done if we had only
|
||||
specified an attribute binding in a regular `src` attribute (`<img src="{{phone.imageUrl}}">`).
|
||||
Using the `ngSrc` directive prevents the browser from making an http request to an invalid location.
|
||||
|
||||
@@ -114,7 +114,7 @@ Our application routes are defined as follows:
|
||||
view, Angular will use the `phone-list.html` template and the `PhoneListCtrl` controller.
|
||||
|
||||
* The phone details view will be shown when the URL hash fragment matches '/phone/:phoneId', where
|
||||
`:phoneId` is a variable part of the URL. To construct the phone details view, angular will use the
|
||||
`:phoneId` is a variable part of the URL. To construct the phone details view, Angular will use the
|
||||
`phone-detail.html` template and the `PhoneDetailCtrl` controller.
|
||||
|
||||
We reused the `PhoneListCtrl` controller that we constructed in previous steps and we added a new,
|
||||
|
||||
@@ -79,7 +79,7 @@ route by the `$route` service.
|
||||
## Template
|
||||
|
||||
The TBD placeholder line has been replaced with lists and bindings that comprise the phone details.
|
||||
Note where we use the angular `{{expression}}` markup and `ngRepeat` to project phone data from
|
||||
Note where we use the Angular `{{expression}}` markup and `ngRepeat` to project phone data from
|
||||
our model into the view.
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ __`app/partials/phone-detail.html`:__
|
||||
</dl>
|
||||
</li>
|
||||
...
|
||||
</li>
|
||||
<li>
|
||||
<span>Additional Features</span>
|
||||
<dd>{{phone.additionalFeatures}}</dd>
|
||||
</li>
|
||||
|
||||
@@ -40,13 +40,13 @@ The name of our filter is "checkmark". The `input` evaluates to either `true` or
|
||||
return one of the two unicode characters we have chosen to represent true (`\u2713` -> ✓) or false (`\u2718` -> ✘).
|
||||
|
||||
Now that our filter is ready, we need to register the `phonecatFilters` module as a dependency for
|
||||
our main `phonecat` module.
|
||||
our main `phonecatApp` module.
|
||||
|
||||
__`app/js/app.js`:__
|
||||
|
||||
```js
|
||||
...
|
||||
angular.module('phonecatApp', ['phonecatFilters']).
|
||||
angular.module('phonecatApp', ['ngRoute','phonecatControllers','phonecatFilters']).
|
||||
...
|
||||
```
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ The most important changes are listed below. You can see the full diff on [GitHu
|
||||
## Template
|
||||
|
||||
The custom service is defined in `app/js/services.js` so we need to include this file in our layout
|
||||
template. Additionally, we also need to load the `angular-resource.js` file, which contains the
|
||||
{@link api/ngResource ngResource} module and in it the {@link api/ngResource.$resource $resource}
|
||||
template. Additionally, we also need to load the `angular-resource.js` file, which contains the
|
||||
{@link api/ngResource ngResource} module and in it the {@link api/ngResource.$resource $resource}
|
||||
service, that we'll soon use:
|
||||
|
||||
__`app/index.html`.__
|
||||
|
||||
@@ -20,7 +20,8 @@ a dependency with the application module, will enable animations throughout the
|
||||
|
||||
Common `ng` directives automatically trigger hooks for animations to tap into. When an animation is found
|
||||
then the animation will run in between the standard DOM operation that is being issued on the element at
|
||||
the given time (e.g. inserting and removing nodes on ngRepeat or adding and removing classes on ngClass).
|
||||
the given time (e.g. inserting and removing nodes on {@link api/ng.directive:ngRepeat `ngRepeat`} or adding
|
||||
and removing classes on {@link api/ng.directive:ngClass `ngClass`}).
|
||||
|
||||
The most important changes are listed below. You can see the full diff on
|
||||
[GitHub](https://github.com/angular/angular-phonecat/compare/step-11...step-12):
|
||||
@@ -34,9 +35,10 @@ To get an idea of how animations work with AngularJS, please read the
|
||||
|
||||
## Template
|
||||
|
||||
The changes required within the HTML template code is to link the asset files which define the animations as well
|
||||
as the `angular-animate.js` file. The animation module, known as `ngAnimate`, is defined within
|
||||
`angular-animate.js` and contains the code necessary to make your application become animation aware.
|
||||
The changes required within the HTML template code is to link the asset files which define the animations as
|
||||
well as the `angular-animate.js` file. The animation module, known as {@link api/ngAnimate `ngAnimate`}, is
|
||||
defined within `angular-animate.js` and contains the code necessary to make your application become animation
|
||||
aware.
|
||||
|
||||
Here's what needs to changed in the index file:
|
||||
|
||||
@@ -83,7 +85,7 @@ __`app/js/app.js`.__
|
||||
|
||||
```js
|
||||
// ...
|
||||
angular.module('phonecat', [
|
||||
angular.module('phonecatApp', [
|
||||
'ngRoute',
|
||||
|
||||
'phonecatAnimations',
|
||||
@@ -197,7 +199,7 @@ which are described in detail below.
|
||||
|
||||
## Animating `ngView` with CSS Keyframe Animations
|
||||
|
||||
Next let's add an animation for transitions between route changes in `ngView`.
|
||||
Next let's add an animation for transitions between route changes in {@link api/ngRoute.directive:ngView `ngView`}.
|
||||
|
||||
To start, let's add a new CSS class to our HTML like we did in the example above.
|
||||
This time, instead of the `ng-repeat` element, let's add it to the element containing the ng-view directive.
|
||||
|
||||
+9
-7
@@ -1,13 +1,12 @@
|
||||
var path = require('canonical-path');
|
||||
var gruntUtils = require('../lib/grunt/utils');
|
||||
var versionInfo = require('../lib/versions/version-info');
|
||||
var basePath = __dirname;
|
||||
|
||||
var basePackage = require('./config');
|
||||
|
||||
module.exports = function(config) {
|
||||
|
||||
var version = gruntUtils.getVersion();
|
||||
var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + version.cdn;
|
||||
var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + versionInfo.currentPackage.cdnVersion;
|
||||
|
||||
var getVersion = function(component, sourceFolder, packageFile) {
|
||||
sourceFolder = sourceFolder || '../bower_components';
|
||||
@@ -25,9 +24,12 @@ module.exports = function(config) {
|
||||
{ pattern: '**/*.ngdoc', basePath: path.resolve(basePath, 'content') }
|
||||
]);
|
||||
|
||||
config.set('processing.stopOnError', true);
|
||||
|
||||
config.set('processing.errors.minerrInfoPath', path.resolve(basePath, '../build/errors.json'));
|
||||
|
||||
config.set('rendering.outputFolder', '../build/docs');
|
||||
config.set('rendering.contentsFolder', 'partials');
|
||||
|
||||
config.set('logging.level', 'info');
|
||||
|
||||
@@ -38,7 +40,7 @@ module.exports = function(config) {
|
||||
commonFiles: {
|
||||
scripts: [ '../../../angular.js' ]
|
||||
},
|
||||
dependencyPath: '../../..'
|
||||
dependencyPath: '../../../'
|
||||
},
|
||||
scripts: [
|
||||
'../angular.js',
|
||||
@@ -73,7 +75,7 @@ module.exports = function(config) {
|
||||
commonFiles: {
|
||||
scripts: [ '../../../angular.min.js' ]
|
||||
},
|
||||
dependencyPath: '../../..'
|
||||
dependencyPath: '../../../'
|
||||
},
|
||||
scripts: [
|
||||
'../angular.min.js',
|
||||
@@ -111,7 +113,7 @@ module.exports = function(config) {
|
||||
'../../../angular.js'
|
||||
]
|
||||
},
|
||||
dependencyPath: '../../..'
|
||||
dependencyPath: '../../../'
|
||||
},
|
||||
scripts: [
|
||||
'components/jquery-' + getVersion('jquery') + '/jquery.js',
|
||||
@@ -147,7 +149,7 @@ module.exports = function(config) {
|
||||
commonFiles: {
|
||||
scripts: [ cdnUrl + '/angular.min.js' ]
|
||||
},
|
||||
dependencyPath: cdnUrl
|
||||
dependencyPath: cdnUrl + '/'
|
||||
},
|
||||
scripts: [
|
||||
cdnUrl + '/angular.min.js',
|
||||
|
||||
+5
-1
@@ -49,7 +49,11 @@ gulp.task('assets', ['bower'], function() {
|
||||
|
||||
|
||||
gulp.task('doc-gen', function() {
|
||||
return docGenerator('docs.config.js').generateDocs();
|
||||
return docGenerator('docs.config.js')
|
||||
.generateDocs()
|
||||
.catch(function(error) {
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
// JSHint the example and protractor test files
|
||||
|
||||
@@ -33,7 +33,7 @@ describe("convertDatetimeData", function() {
|
||||
AMPMS: ['AM', 'PM'],
|
||||
DATEFORMATS: ['a', 'b', 'c', 'd'],
|
||||
TIMEFORMATS: ['e', 'f', 'g', 'h'] };
|
||||
|
||||
|
||||
it('should convert empty datetime obj', function() {
|
||||
var processedData = convert(dataObj);
|
||||
expect(processedData.MONTH).toEqual(['Enero', 'Pebrero']);
|
||||
|
||||
+2
-2
@@ -7,10 +7,10 @@ echo "#################################"
|
||||
# Enable tracing and exit on first failure
|
||||
set -xe
|
||||
|
||||
# Define reasonable set of browsers in case we are running manually from commandline
|
||||
# This is the default set of browsers to use on the CI server unless overridden via env variable
|
||||
if [[ -z "$BROWSERS" ]]
|
||||
then
|
||||
BROWSERS="Chrome,Firefox,Opera,/Users/jenkins/bin/safari.sh,/Users/jenkins/bin/ie8.sh,/Users/jenkins/bin/ie9.sh"
|
||||
BROWSERS="Chrome,Firefox,Opera,/Users/jenkins/bin/safari.sh"
|
||||
fi
|
||||
|
||||
# CLEAN #
|
||||
|
||||
@@ -45,12 +45,6 @@ module.exports = function(config, specificOptions) {
|
||||
platform: 'OS X 10.9',
|
||||
version: '7'
|
||||
},
|
||||
'SL_IE_8': {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 7',
|
||||
version: '8'
|
||||
},
|
||||
'SL_IE_9': {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'internet explorer',
|
||||
@@ -88,13 +82,6 @@ module.exports = function(config, specificOptions) {
|
||||
os: 'Windows',
|
||||
os_version: '8'
|
||||
},
|
||||
'BS_IE_8': {
|
||||
base: 'BrowserStack',
|
||||
browser: 'ie',
|
||||
browser_version: '8.0',
|
||||
os: 'Windows',
|
||||
os_version: '7'
|
||||
},
|
||||
'BS_IE_9': {
|
||||
base: 'BrowserStack',
|
||||
browser: 'ie',
|
||||
|
||||
+6
-176
@@ -4,8 +4,9 @@ var shell = require('shelljs');
|
||||
var grunt = require('grunt');
|
||||
var spawn = require('child_process').spawn;
|
||||
var semver = require('semver');
|
||||
|
||||
var _ = require('lodash');
|
||||
var version, pkg;
|
||||
|
||||
var CSP_CSS_HEADER = '/* Include this file in your html if you are using the CSP mode. */\n\n';
|
||||
|
||||
var PORT_MIN = 8000;
|
||||
@@ -23,23 +24,6 @@ var getRandomPorts = function() {
|
||||
];
|
||||
};
|
||||
|
||||
var getPackage = function() {
|
||||
if ( !pkg ) {
|
||||
|
||||
// Search up the folder hierarchy for the first package.json
|
||||
var packageFolder = path.resolve('.');
|
||||
while ( !fs.existsSync(path.join(packageFolder, 'package.json')) ) {
|
||||
var parent = path.dirname(packageFolder);
|
||||
if ( parent === packageFolder) { break; }
|
||||
packageFolder = parent;
|
||||
}
|
||||
pkg = JSON.parse(fs.readFileSync(path.join(packageFolder,'package.json'), 'UTF-8'));
|
||||
|
||||
}
|
||||
|
||||
return pkg;
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -50,160 +34,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
|
||||
getGitRepoInfo: function() {
|
||||
var GITURL_REGEX = /^https:\/\/github.com\/([^\/]+)\/(.+).git$/;
|
||||
var match = GITURL_REGEX.exec(getPackage().repository.url);
|
||||
var git = {
|
||||
owner: match[1],
|
||||
repo: match[2]
|
||||
};
|
||||
return git;
|
||||
},
|
||||
|
||||
|
||||
getVersion: function(){
|
||||
if (version) return version;
|
||||
|
||||
try {
|
||||
|
||||
var gitTag = getTagOfCurrentCommit();
|
||||
var semVerVersion, codeName, fullVersion;
|
||||
if (gitTag) {
|
||||
// tagged release
|
||||
fullVersion = semVerVersion = semver.valid(gitTag);
|
||||
codeName = getTaggedReleaseCodeName(gitTag);
|
||||
} else {
|
||||
// snapshot release
|
||||
semVerVersion = getSnapshotVersion();
|
||||
fullVersion = semVerVersion + '-' + getSnapshotSuffix();
|
||||
codeName = 'snapshot';
|
||||
}
|
||||
|
||||
var versionParts = semVerVersion.match(/(\d+)\.(\d+)\.(\d+)/);
|
||||
|
||||
version = {
|
||||
full: fullVersion,
|
||||
major: versionParts[1],
|
||||
minor: versionParts[2],
|
||||
dot: versionParts[3],
|
||||
codename: codeName,
|
||||
cdn: getPackage().cdnVersion
|
||||
};
|
||||
|
||||
// Stable versions have an even minor version
|
||||
version.isStable = version.minor%2 === 0;
|
||||
|
||||
return version;
|
||||
|
||||
} catch (e) {
|
||||
grunt.fail.warn(e);
|
||||
}
|
||||
|
||||
function getTagOfCurrentCommit() {
|
||||
var gitTagResult = shell.exec('git describe --exact-match', {silent:true});
|
||||
var gitTagOutput = gitTagResult.output.trim();
|
||||
var branchVersionPattern = new RegExp(getPackage().branchVersion.replace('.', '\\.').replace('*', '\\d+'));
|
||||
if (gitTagResult.code === 0 && gitTagOutput.match(branchVersionPattern)) {
|
||||
return gitTagOutput;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getTaggedReleaseCodeName(tagName) {
|
||||
var tagMessage = shell.exec('git cat-file -p '+ tagName +' | grep "codename"', {silent:true}).output;
|
||||
var codeName = tagMessage && tagMessage.match(/codename\((.*)\)/)[1];
|
||||
if (!codeName) {
|
||||
throw new Error("Could not extract release code name. The message of tag "+tagName+
|
||||
" must match '*codename(some release name)*'");
|
||||
}
|
||||
return codeName;
|
||||
}
|
||||
|
||||
function getSnapshotVersion() {
|
||||
var oldTags = shell.exec('git tag -l v'+getPackage().branchVersion, {silent:true}).output.trim().split('\n');
|
||||
// ignore non semver versions.
|
||||
oldTags = oldTags.filter(function(version) {
|
||||
return version && semver.valid(version);
|
||||
});
|
||||
if (oldTags.length) {
|
||||
oldTags.sort(semver.compare);
|
||||
semVerVersion = oldTags[oldTags.length-1];
|
||||
if (semVerVersion.indexOf('-') !== -1) {
|
||||
semVerVersion = semver.inc(semVerVersion, 'prerelease');
|
||||
} else {
|
||||
semVerVersion = semver.inc(semVerVersion, 'patch');
|
||||
}
|
||||
} else {
|
||||
semVerVersion = semver.valid(getPackage().branchVersion.replace(/\*/g, '0'));
|
||||
}
|
||||
return semVerVersion;
|
||||
}
|
||||
|
||||
function getSnapshotSuffix() {
|
||||
var jenkinsBuild = process.env.TRAVIS_BUILD_NUMBER || process.env.BUILD_NUMBER || 'local';
|
||||
var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', '');
|
||||
return 'build.'+jenkinsBuild+'+sha.'+hash;
|
||||
}
|
||||
},
|
||||
|
||||
getPreviousVersions: function() {
|
||||
var VERSION_REGEX = /([1-9]\d*)\.(\d+)\.(\d+)(?:-?rc\.?(\d+)|-(snapshot))?/;
|
||||
|
||||
// Pad out a number with zeros at the front to make it `digits` characters long
|
||||
function pad(num, digits) {
|
||||
var zeros = Array(digits+1).join('0');
|
||||
return (zeros+num).slice(-digits);
|
||||
}
|
||||
|
||||
function padVersion(version) {
|
||||
// We pad out the version numbers with 0s so they sort nicely
|
||||
// - Non-Release Candidates get 9999 for their release candidate section to make them appear earlier
|
||||
// - Snapshots get 9 added to the front to move them to the top of the list
|
||||
var maxLength = 4;
|
||||
var padded = (version.snapshot ? '9' : '0') + pad(version.major, maxLength) +
|
||||
pad(version.minor, maxLength) + pad(version.dot, maxLength) +
|
||||
pad(version.rc || 9999, maxLength);
|
||||
return padded;
|
||||
}
|
||||
|
||||
function getVersionFromTag(tag) {
|
||||
var match = VERSION_REGEX.exec(tag);
|
||||
if ( match ) {
|
||||
var version = {
|
||||
tag: tag,
|
||||
major: match[1], minor: match[2], dot: match[3], rc: match[4],
|
||||
snapshot: !!match[5] && getSnapshotSuffix()
|
||||
};
|
||||
|
||||
if(version.snapshot) {
|
||||
version.full = version.major + '.' + version.minor + '.x (edge)';
|
||||
} else {
|
||||
version.full = version.major + '.' + version.minor + '.' + version.dot +
|
||||
(version.rc ? '-rc.' + version.rc : '');
|
||||
}
|
||||
|
||||
// Stable versions have an even minor version and are not a release candidate
|
||||
version.isStable = !(version.minor%2 || version.rc);
|
||||
|
||||
// Versions before 1.0.2 had a different docs folder name
|
||||
version.docsUrl = 'http://code.angularjs.org/' + version.full + '/docs';
|
||||
if ( version.major < 1 || (version.major === 1 && version.minor === 0 && version.dot < 2 ) ) {
|
||||
version.docsUrl += '-' + version.full;
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
var tags = shell.exec('git tag', {silent: true}).output.split(/\s*\n\s*/);
|
||||
return _(tags)
|
||||
.map(getVersionFromTag)
|
||||
.filter() // getVersion can map to undefined - this clears those out
|
||||
.sortBy(padVersion)
|
||||
.value();
|
||||
},
|
||||
|
||||
startKarma: function(config, singleRun, done){
|
||||
var browsers = grunt.option('browsers');
|
||||
var reporters = grunt.option('reporters');
|
||||
@@ -225,7 +55,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
|
||||
updateWebdriver: function(done){
|
||||
updateWebdriver: function(done){
|
||||
if (process.env.TRAVIS) {
|
||||
// Skip the webdriver-manager update on Travis, since the browsers will
|
||||
// be provided remotely.
|
||||
@@ -319,9 +149,9 @@ module.exports = {
|
||||
.replace(/"NG_VERSION_FULL"/g, NG_VERSION.full)
|
||||
.replace(/"NG_VERSION_MAJOR"/, NG_VERSION.major)
|
||||
.replace(/"NG_VERSION_MINOR"/, NG_VERSION.minor)
|
||||
.replace(/"NG_VERSION_DOT"/, NG_VERSION.dot)
|
||||
.replace(/"NG_VERSION_DOT"/, NG_VERSION.patch)
|
||||
.replace(/"NG_VERSION_CDN"/, NG_VERSION.cdn)
|
||||
.replace(/"NG_VERSION_CODENAME"/, NG_VERSION.codename);
|
||||
.replace(/"NG_VERSION_CODENAME"/, NG_VERSION.codeName);
|
||||
if (strict !== false) processed = this.singleStrict(processed, '\n\n', true);
|
||||
return processed;
|
||||
},
|
||||
@@ -374,7 +204,7 @@ module.exports = {
|
||||
var mapFile = minFile + '.map';
|
||||
var mapFileName = mapFile.match(/[^\/]+$/)[0];
|
||||
var errorFileName = file.replace(/\.js$/, '-errors.json');
|
||||
var versionNumber = this.getVersion().full;
|
||||
var versionNumber = grunt.config('NG_VERSION').full;
|
||||
shell.exec(
|
||||
'java ' +
|
||||
this.java32flags() + ' ' +
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var shell = require('shelljs');
|
||||
var semver = require('semver');
|
||||
var _ = require('lodash');
|
||||
|
||||
var currentPackage, previousVersions;
|
||||
|
||||
|
||||
/**
|
||||
* Load information about this project from the package.json
|
||||
* @return {Object} The package information
|
||||
*/
|
||||
var getPackage = function() {
|
||||
// Search up the folder hierarchy for the first package.json
|
||||
var packageFolder = path.resolve('.');
|
||||
while ( !fs.existsSync(path.join(packageFolder, 'package.json')) ) {
|
||||
var parent = path.dirname(packageFolder);
|
||||
if ( parent === packageFolder) { break; }
|
||||
packageFolder = parent;
|
||||
}
|
||||
return JSON.parse(fs.readFileSync(path.join(packageFolder,'package.json'), 'UTF-8'));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse the github URL for useful information
|
||||
* @return {Object} An object containing the github owner and repository name
|
||||
*/
|
||||
var getGitRepoInfo = function() {
|
||||
var GITURL_REGEX = /^https:\/\/github.com\/([^\/]+)\/(.+).git$/;
|
||||
var match = GITURL_REGEX.exec(currentPackage.repository.url);
|
||||
var git = {
|
||||
owner: match[1],
|
||||
repo: match[2]
|
||||
};
|
||||
return git;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extract the code name from the tagged commit's message - it should contain the text of the form:
|
||||
* "codename(some-code-name)"
|
||||
* @param {String} tagName Name of the tag to look in for the codename
|
||||
* @return {String} The codename if found, otherwise null/undefined
|
||||
*/
|
||||
var getCodeName = function(tagName) {
|
||||
var tagMessage = shell.exec('git cat-file -p '+ tagName +' | grep "codename"', {silent:true}).output;
|
||||
var codeName = tagMessage && tagMessage.match(/codename\((.*)\)/)[1];
|
||||
if (!codeName) {
|
||||
throw new Error("Could not extract release code name. The message of tag "+tagName+
|
||||
" must match '*codename(some release name)*'");
|
||||
}
|
||||
return codeName;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Compute a build segment for the version, from the Jenkins build number and current commit SHA
|
||||
* @return {String} The build segment of the version
|
||||
*/
|
||||
function getBuild() {
|
||||
var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', '');
|
||||
return 'sha.'+hash;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If the current commit is tagged as a version get that version
|
||||
* @return {SemVer} The version or null
|
||||
*/
|
||||
var getTaggedVersion = function() {
|
||||
var gitTagResult = shell.exec('git describe --exact-match', {silent:true});
|
||||
|
||||
if ( gitTagResult.code === 0 ) {
|
||||
var tag = gitTagResult.output.trim();
|
||||
var version = semver.parse(tag);
|
||||
|
||||
if ( version && semver.satisfies(version, currentPackage.branchVersion)) {
|
||||
version.codeName = getCodeName(tag);
|
||||
version.full = version.version;
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Stable versions have an even minor version and have no prerelease
|
||||
* @param {SemVer} version The version to test
|
||||
* @return {Boolean} True if the version is stable
|
||||
*/
|
||||
var isStable = function(version) {
|
||||
return semver.satisfies(version, '1.0 || 1.2') && version.prerelease.length === 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a collection of all the previous versions sorted by semantic version
|
||||
* @return {Array.<SemVer>} The collection of previous versions
|
||||
*/
|
||||
var getPreviousVersions = function() {
|
||||
// always use the remote tags as the local clone might
|
||||
// not contain all commits when cloned with git clone --depth=...
|
||||
// Needed e.g. for Travis
|
||||
var repo_url = currentPackage.repository.url;
|
||||
var tagResults = shell.exec('git ls-remote --tags ' + repo_url + ' | grep -o -e "v[0-9].*[0-9]$"',
|
||||
{silent: true});
|
||||
if ( tagResults.code === 0 ) {
|
||||
return _(tagResults.output.trim().split('\n'))
|
||||
.map(function(tag) {
|
||||
var version = semver.parse(tag);
|
||||
return version;
|
||||
})
|
||||
.filter()
|
||||
.map(function(version) {
|
||||
version.isStable = isStable(version);
|
||||
|
||||
version.docsUrl = 'http://code.angularjs.org/' + version.version + '/docs';
|
||||
// Versions before 1.0.2 had a different docs folder name
|
||||
if ( version.major < 1 || (version.major === 1 && version.minor === 0 && version.dot < 2 ) ) {
|
||||
version.docsUrl += '-' + version.version;
|
||||
}
|
||||
return version;
|
||||
})
|
||||
.sort(semver.compare)
|
||||
.value();
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the unstable snapshot version
|
||||
* @return {SemVer} The snapshot version
|
||||
*/
|
||||
var getSnapshotVersion = function() {
|
||||
version = _(previousVersions)
|
||||
.filter(function(tag) {
|
||||
return semver.satisfies(tag, currentPackage.branchVersion);
|
||||
})
|
||||
.last();
|
||||
|
||||
if ( !version ) {
|
||||
// a snapshot version before the first tag on the branch
|
||||
version = semver(currentPackage.branchVersion.replace('*','0-beta.1'));
|
||||
}
|
||||
|
||||
// We need to clone to ensure that we are not modifying another version
|
||||
version = semver(version.raw);
|
||||
|
||||
var jenkinsBuild = process.env.TRAVIS_BUILD_NUMBER || process.env.BUILD_NUMBER;
|
||||
if (!version.prerelease || !version.prerelease.length) {
|
||||
// last release was a non beta release. Increment the patch level to
|
||||
// indicate the next release that we will be doing.
|
||||
// E.g. last release was 1.3.0, then the snapshot will be
|
||||
// 1.3.1-build.1, which is lesser than 1.3.1 accorind the semver!
|
||||
|
||||
// If the last release was a beta release we don't update the
|
||||
// beta number by purpose, as otherwise the semver comparison
|
||||
// does not work any more when the next beta is released.
|
||||
// E.g. don't generate 1.3.0-beta.2.build.1
|
||||
// as this is bigger than 1.3.0-beta.2 according to semver
|
||||
version.patch++;
|
||||
}
|
||||
version.prerelease = jenkinsBuild ? ['build', jenkinsBuild] : ['local'];
|
||||
version.build = getBuild();
|
||||
version.codeName = 'snapshot';
|
||||
version.isSnapshot = true;
|
||||
version.format();
|
||||
version.full = version.version + '+' + version.build;
|
||||
|
||||
return version;
|
||||
};
|
||||
|
||||
|
||||
exports.currentPackage = currentPackage = getPackage();
|
||||
exports.gitRepoInfo = gitRepoInfo = getGitRepoInfo();
|
||||
exports.previousVersions = previousVersions = getPreviousVersions();
|
||||
exports.currentVersion = getTaggedVersion() || getSnapshotVersion();
|
||||
Generated
+2808
File diff suppressed because it is too large
Load Diff
+9
-7
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "angularjs",
|
||||
"branchVersion": "1.2.*",
|
||||
"cdnVersion": "1.2.14",
|
||||
"branchVersion": "1.3.*",
|
||||
"cdnVersion": "1.3.0-beta.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/angular/angular.js.git"
|
||||
@@ -16,7 +16,7 @@
|
||||
"grunt-contrib-jshint": "~0.7.2",
|
||||
"grunt-ddescribe-iit": "~0.0.1",
|
||||
"grunt-jasmine-node": "git://github.com/vojtajina/grunt-jasmine-node.git#fix-grunt-exit-code",
|
||||
"grunt-jscs-checker": "~0.3.2",
|
||||
"grunt-jscs-checker": "~0.4.0",
|
||||
"grunt-merge-conflict": "~0.0.1",
|
||||
"grunt-parallel": "~0.3.1",
|
||||
"grunt-shell": "~0.4.0",
|
||||
@@ -27,7 +27,7 @@
|
||||
"q-io": "~1.10.6",
|
||||
"qq": "~0.3.5",
|
||||
"shelljs": "~0.2.6",
|
||||
"karma": "0.11.12",
|
||||
"karma": "^0.12.0",
|
||||
"karma-jasmine": "0.1.5",
|
||||
"karma-chrome-launcher": "0.1.2",
|
||||
"karma-firefox-launcher": "0.1.3",
|
||||
@@ -50,10 +50,12 @@
|
||||
"gulp-concat": "~2.1.7",
|
||||
"canonical-path": "0.0.2",
|
||||
"winston": "~0.7.2",
|
||||
"dgeni": "~0.2.0",
|
||||
"dgeni-packages": "^0.3.0",
|
||||
"dgeni": "^0.2.2",
|
||||
"dgeni-packages": "^0.8.1",
|
||||
"gulp-jshint": "~1.4.2",
|
||||
"jshint-stylish": "~0.1.5"
|
||||
"jshint-stylish": "~0.1.5",
|
||||
"node-html-encoder": "0.0.2",
|
||||
"sorted-object": "^1.0.0"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
|
||||
@@ -11,8 +11,11 @@ ARG_DEFS=(
|
||||
)
|
||||
|
||||
function init {
|
||||
TMP_DIR=$(resolveDir ../../tmp)
|
||||
BASE_DIR=$(resolveDir ../..)
|
||||
TMP_DIR=$BASE_DIR/tmp
|
||||
REPO_DIR=$TMP_DIR/angularjs.org
|
||||
BRANCH_PATTERN=$(readJsonProp "$BASE_DIR/package.json" "branchVersion")
|
||||
BUILD_DIR=$BASE_DIR/build
|
||||
}
|
||||
|
||||
function prepare {
|
||||
@@ -24,18 +27,24 @@ function prepare {
|
||||
#
|
||||
echo "-- Updating angularjs.org"
|
||||
cd $REPO_DIR
|
||||
VERSION_REGEX="[a-z0-9\-\.\+]+"
|
||||
VERSION_REGEX="[-a-z0-9\.\+]+"
|
||||
|
||||
replaceInFile "index.html" "(ajax\/libs\/angularjs\/)$VERSION_REGEX" "\1$CDN_VERSION"
|
||||
replaceInFile "index.html" "(<span class=\"version\">[^<]*<span>)$VERSION_REGEX" "\1$CDN_VERSION"
|
||||
replaceInFile "index.html" "(code.angularjs.org\/)$VERSION_REGEX" "\1$CDN_VERSION"
|
||||
# Replace the version in the script links that reference the Google CDN
|
||||
# e.g. <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.1/angular.js"></script>
|
||||
replaceInFile "index.html" "(http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/)$VERSION_REGEX" "\1$CDN_VERSION"
|
||||
|
||||
replaceInFile "js/homepage.js" "($scope.CURRENT_STABLE_VERSION[ ]*=[ ]*')$VERSION_REGEX" "\1$CDN_VERSION"
|
||||
replaceInFile "js/homepage.js" "($scope.CURRENT_UNSTABLE_VERSION[ ]*=[ ]*')$VERSION_REGEX" "\1$CDN_VERSION"
|
||||
# Replace the version in the script links that reference code.angularjs.org
|
||||
# e.g. <script src="http://code.angularjs.org/1.3.0-beta.1/i18n/angular-locale_sk.js"></script>
|
||||
replaceInFile "index.html" "(code\.angularjs\.org\/)$VERSION_REGEX" "\1$CDN_VERSION"
|
||||
|
||||
# Replace the version of the branch that we are updating
|
||||
echo $BRANCH_PATTERN
|
||||
echo $CDN_VERSION
|
||||
replaceInFile "js/download-data.js" "branch:[ ]+'($BRANCH_PATTERN)',[ ]+version:[ ]+'$VERSION_REGEX'" "branch: '\1', version: '$CDN_VERSION'"
|
||||
|
||||
git add index.html
|
||||
git add js/homepage.js
|
||||
git commit -m "update(version): update angular version to $CDN_VERSION"
|
||||
git add js/download-data.js
|
||||
git commit -m "update(version): update angular version to $CDN_VERSION for branch $BRANCH_PATTERN"
|
||||
}
|
||||
|
||||
function publish {
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* this script is just a temporary solution to deal with the issue of npm outputting the npm
|
||||
* shrinkwrap file in an unstable manner.
|
||||
*
|
||||
* See: https://github.com/npm/npm/issues/3581
|
||||
*/
|
||||
|
||||
var _ = require('lodash');
|
||||
var sorted = require('sorted-object');
|
||||
var fs = require('fs');
|
||||
|
||||
|
||||
function cleanModule(module, name) {
|
||||
|
||||
// keep `from` and `resolve` properties for git dependencies, delete otherwise
|
||||
if (!(module.resolved && module.resolved.match(/^git:\/\//))) {
|
||||
delete module.from;
|
||||
delete module.resolved;
|
||||
}
|
||||
|
||||
if (name === 'chokidar') {
|
||||
if (module.version === '0.8.1') {
|
||||
delete module.dependencies;
|
||||
} else {
|
||||
throw new Error("Unfamiliar chokidar version (v" + module.version +
|
||||
") , please check status of https://github.com/paulmillr/chokidar/pull/106");
|
||||
}
|
||||
}
|
||||
|
||||
_.forEach(module.dependencies, function(mod, name) {
|
||||
cleanModule(mod, name);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
console.log('Reading npm-shrinkwrap.json');
|
||||
var shrinkwrap = require('./../npm-shrinkwrap.json');
|
||||
|
||||
console.log('Cleaning shrinkwrap object');
|
||||
cleanModule(shrinkwrap, shrinkwrap.name);
|
||||
|
||||
console.log('Writing cleaned npm-shrinkwrap.json');
|
||||
fs.writeFileSync('./npm-shrinkwrap.json', JSON.stringify(sorted(shrinkwrap), null, 2) + "\n");
|
||||
@@ -55,19 +55,37 @@ function prepare {
|
||||
git commit -m "v$NEW_VERSION"
|
||||
}
|
||||
|
||||
function publish {
|
||||
if [[ $IS_SNAPSHOT_BUILD ]]; then
|
||||
echo "-- Updating snapshot version"
|
||||
curl -G --data-urlencode "ver=$NEW_VERSION" http://code.angularjs.org/fetchLatestSnapshot.php
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
function _update_snapshot() {
|
||||
for backend in "$@" ; do
|
||||
echo "-- Updating snapshot version: backend=$backend"
|
||||
curl -G --data-urlencode "ver=$NEW_VERSION" http://$backend:8003/fetchLatestSnapshot.php
|
||||
done
|
||||
}
|
||||
|
||||
function _update_code() {
|
||||
cd $REPO_DIR
|
||||
|
||||
echo "-- Pushing code.angularjs.org"
|
||||
git push origin master
|
||||
|
||||
echo "-- Refreshing code.angularjs.org"
|
||||
curl http://code.angularjs.org/gitFetchSite.php
|
||||
for backend in "$@" ; do
|
||||
echo "-- Refreshing code.angularjs.org: backend=$backend"
|
||||
curl http://$backend:8003/gitFetchSite.php
|
||||
done
|
||||
}
|
||||
|
||||
function publish {
|
||||
# The TXT record for backends.angularjs.org is a CSV of the IP addresses for
|
||||
# the currently serving Compute Engine backends.
|
||||
# code.angularjs.org is served out of port 8003 on these backends.
|
||||
backends=("$(dig backends.angularjs.org +short TXT | python -c 'print raw_input()[1:-1].replace(",", "\n")')")
|
||||
|
||||
if [[ $IS_SNAPSHOT_BUILD ]]; then
|
||||
_update_snapshot ${backends[@]}
|
||||
else
|
||||
_update_code ${backends[@]}
|
||||
fi
|
||||
}
|
||||
|
||||
source $(dirname $0)/../utils.inc
|
||||
|
||||
@@ -23,7 +23,7 @@ ARG_DEFS=(
|
||||
)
|
||||
|
||||
function init {
|
||||
if [[ $(git rev-parse --short HEAD) != $COMMIT_SHA ]]; then
|
||||
if [[ $(git rev-parse HEAD) != $(git rev-parse $COMMIT_SHA) ]]; then
|
||||
echo "HEAD is not at $COMMIT_SHA"
|
||||
usage
|
||||
fi
|
||||
|
||||
@@ -7,8 +7,8 @@ export SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev`
|
||||
if [ $JOB = "unit" ]; then
|
||||
grunt ci-checks
|
||||
grunt test:promises-aplus
|
||||
grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
|
||||
grunt test:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_8,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
|
||||
grunt test:unit --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
|
||||
grunt test:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
|
||||
elif [ $JOB = "e2e" ]; then
|
||||
export TARGET_SPECS="build/docs/ptore2e/**/*jqlite_test.js"
|
||||
if [ $TEST_TARGET = "jquery" ]; then
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@
|
||||
# 0. Set the current directory to the directory of the script. By this
|
||||
# the script can be called from anywhere.
|
||||
# 1. Parse the named arguments
|
||||
# 2. If the parameter "git_push_dryrun" is set, all calls the `git push` in this script
|
||||
# 2. If the parameter "git_push_dryrun" is set, all calls to `git push` in this script
|
||||
# or in child scripts will be intercepted so that the `--dry-run` and `--porcelain` is added
|
||||
# to show what the push would do but not actually do it.
|
||||
# 3. If the parameter "verbose" is set, the `-x` flag will be set in bash.
|
||||
@@ -36,7 +36,7 @@
|
||||
# with the name of the parameter in upper case (with dash converted to underscore).
|
||||
#
|
||||
# Special arguments that are always available:
|
||||
# - "--action=.*": This parameter will be used to dispatch to a function with that name when the
|
||||
# - "--action=.*": This parameter will be used to execute a function with that name when the
|
||||
# script is started
|
||||
# - "--git_push_dryrun=true": This will intercept all calls to `git push` in this script
|
||||
# or in child scripts so that the `--dry-run` and `--porcelain` is added
|
||||
@@ -195,7 +195,7 @@ function isFunction {
|
||||
}
|
||||
|
||||
# readJsonProp(jsonFile, property)
|
||||
# - restriction: property needs to be on an own line!
|
||||
# - restriction: property needs to be on a single line!
|
||||
function readJsonProp {
|
||||
echo $(sed -En 's/.*"'$2'"[ ]*:[ ]*"(.*)".*/\1/p' $1)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
"isWindow": false,
|
||||
"isScope": false,
|
||||
"isFile": false,
|
||||
"isBlob": false,
|
||||
"isBoolean": false,
|
||||
"trim": false,
|
||||
"isElement": false,
|
||||
@@ -101,6 +102,9 @@
|
||||
"getter": false,
|
||||
"getBlockElements": false,
|
||||
|
||||
/* filters.js */
|
||||
"getFirstThursdayOfYear": false,
|
||||
|
||||
/* AngularPublic.js */
|
||||
"version": false,
|
||||
"publishExternalAPI": false,
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
-isWindow,
|
||||
-isScope,
|
||||
-isFile,
|
||||
-isBlob,
|
||||
-isBoolean,
|
||||
-trim,
|
||||
-isElement,
|
||||
@@ -566,6 +567,11 @@ function isFile(obj) {
|
||||
}
|
||||
|
||||
|
||||
function isBlob(obj) {
|
||||
return toString.call(obj) === '[object Blob]';
|
||||
}
|
||||
|
||||
|
||||
function isBoolean(value) {
|
||||
return typeof value === 'boolean';
|
||||
}
|
||||
@@ -1235,6 +1241,41 @@ function angularInit(element, bootstrap) {
|
||||
* Note that ngScenario-based end-to-end tests cannot use this function to bootstrap manually.
|
||||
* They must use {@link ng.directive:ngApp ngApp}.
|
||||
*
|
||||
* Angular will detect if it has been loaded into the browser more than once and only allow the
|
||||
* first loaded script to be bootstrapped and will report a warning to the browser console for
|
||||
* each of the subsequent scripts. This prevents strange results in applications, where otherwise
|
||||
* multiple instances of Angular try to work on the DOM.
|
||||
*
|
||||
* <example name="multi-bootstrap" module="multi-bootstrap">
|
||||
* <file name="index.html">
|
||||
* <script src="../../../angular.js"></script>
|
||||
* <div ng-controller="BrokenTable">
|
||||
* <table>
|
||||
* <tr>
|
||||
* <th ng-repeat="heading in headings">{{heading}}</th>
|
||||
* </tr>
|
||||
* <tr ng-repeat="filling in fillings">
|
||||
* <td ng-repeat="fill in filling">{{fill}}</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </div>
|
||||
* </file>
|
||||
* <file name="controller.js">
|
||||
* var app = angular.module('multi-bootstrap', [])
|
||||
*
|
||||
* .controller('BrokenTable', function($scope) {
|
||||
* $scope.headings = ['One', 'Two', 'Three'];
|
||||
* $scope.fillings = [[1, 2, 3], ['A', 'B', 'C'], [7, 8, 9]];
|
||||
* });
|
||||
* </file>
|
||||
* <file name="protractor.js" type="protractor">
|
||||
* it('should only insert one table cell for each item in $scope.fillings', function() {
|
||||
* expect(element.all(by.css('td')).count())
|
||||
* .toBe(9);
|
||||
* });
|
||||
* </file>
|
||||
* </example>
|
||||
*
|
||||
* @param {Element} element DOM element which is the root of angular application.
|
||||
* @param {Array<String|Function|Array>=} modules an array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
if (window.angular.bootstrap) {
|
||||
//AngularJS is already loaded, so we can return here...
|
||||
console.log('WARNING: Tried to load angular more than once.');
|
||||
return;
|
||||
}
|
||||
|
||||
//try to bind to jquery now so that one can write angular.element().read()
|
||||
//but we will rebind on bootstrap again.
|
||||
bindJQuery();
|
||||
|
||||
+7
-3
@@ -364,11 +364,15 @@ function jqLiteInheritedData(element, name, value) {
|
||||
var names = isArray(name) ? name : [name];
|
||||
|
||||
while (element.length) {
|
||||
|
||||
var node = element[0];
|
||||
for (var i = 0, ii = names.length; i < ii; i++) {
|
||||
if ((value = element.data(names[i])) !== undefined) return value;
|
||||
}
|
||||
element = element.parent();
|
||||
|
||||
// If dealing with a document fragment node with a host element, and no parent, use the host
|
||||
// element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM
|
||||
// to lookup parent controllers.
|
||||
element = jqLite(node.parentNode || (node.nodeType === 11 && node.host));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,7 +461,7 @@ forEach({
|
||||
return jqLite(element).data('$isolateScope') || jqLite(element).data('$isolateScopeNoTemplate');
|
||||
},
|
||||
|
||||
controller: jqLiteController ,
|
||||
controller: jqLiteController,
|
||||
|
||||
injector: function(element) {
|
||||
return jqLiteInheritedData(element, '$injector');
|
||||
|
||||
+2
-4
@@ -55,10 +55,10 @@ function setupModuleLoader(window) {
|
||||
* myModule.value('appName', 'MyCoolApp');
|
||||
*
|
||||
* // configure existing services inside initialization blocks.
|
||||
* myModule.config(function($locationProvider) {
|
||||
* myModule.config(['$locationProvider', function($locationProvider) {
|
||||
* // Configure existing providers
|
||||
* $locationProvider.hashPrefix('!');
|
||||
* });
|
||||
* }]);
|
||||
* ```
|
||||
*
|
||||
* Then you can create an injector and load your modules like this:
|
||||
@@ -114,7 +114,6 @@ function setupModuleLoader(window) {
|
||||
* @ngdoc property
|
||||
* @name angular.Module#requires
|
||||
* @module ng
|
||||
* @propertyOf angular.Module
|
||||
* @returns {Array.<string>} List of module names which must be loaded before this module.
|
||||
* @description
|
||||
* Holds the list of modules which the injector will load before the current module is
|
||||
@@ -126,7 +125,6 @@ function setupModuleLoader(window) {
|
||||
* @ngdoc property
|
||||
* @name angular.Module#name
|
||||
* @module ng
|
||||
* @propertyOf angular.Module
|
||||
* @returns {string} Name of the module.
|
||||
* @description
|
||||
*/
|
||||
|
||||
+1
-1
@@ -194,7 +194,6 @@ function Browser(window, document, $log, $sniffer) {
|
||||
|
||||
/**
|
||||
* @name $browser#onUrlChange
|
||||
* @TODO(vojta): refactor to use node's syntax for events
|
||||
*
|
||||
* @description
|
||||
* Register callback function that will be called, when url changes.
|
||||
@@ -215,6 +214,7 @@ function Browser(window, document, $log, $sniffer) {
|
||||
* @return {function(string)} Returns the registered listener fn - handy if the fn is anonymous.
|
||||
*/
|
||||
self.onUrlChange = function(callback) {
|
||||
// TODO(vojta): refactor to use node's syntax for events
|
||||
if (!urlChangeInit) {
|
||||
// We listen on both (hashchange/popstate) when available, as some browsers (e.g. Opera)
|
||||
// don't fire popstate when user change the address bar and don't fire hashchange when url
|
||||
|
||||
@@ -208,15 +208,11 @@ function $CacheFactoryProvider() {
|
||||
* `$templateCache` service directly.
|
||||
*
|
||||
* Adding via the `script` tag:
|
||||
*
|
||||
* ```html
|
||||
* <html ng-app>
|
||||
* <head>
|
||||
* <script type="text/ng-template" id="templateId.html">
|
||||
* This is the content of the template
|
||||
* </script>
|
||||
* </head>
|
||||
* ...
|
||||
* </html>
|
||||
* <script type="text/ng-template" id="templateId.html">
|
||||
* <p>This is the content of the template</p>
|
||||
* </script>
|
||||
* ```
|
||||
*
|
||||
* **Note:** the `script` tag containing the template does not need to be included in the `head` of
|
||||
|
||||
+13
-11
@@ -503,7 +503,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
Suffix = 'Directive',
|
||||
COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/,
|
||||
CLASS_DIRECTIVE_REGEXP = /(([\d\w\-_]+)(?:\:([^;]+))?;?)/,
|
||||
TABLE_CONTENT_REGEXP = /^<\s*(tr|th|td|tbody)(\s+[^>]*)?>/i;
|
||||
TABLE_CONTENT_REGEXP = /^<\s*(tr|th|td|thead|tbody|tfoot)(\s+[^>]*)?>/i;
|
||||
|
||||
// Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes
|
||||
// The assumption is that future DOM event attribute names will begin with
|
||||
@@ -775,7 +775,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
* @param {function(interpolatedValue)} fn Function that will be called whenever
|
||||
the interpolated value of the attribute changes.
|
||||
* See the {@link guide/directive#Attributes Directives} guide for more info.
|
||||
* @returns {function()} the `fn` parameter.
|
||||
* @returns {function()} Returns a deregistration function for this observer.
|
||||
*/
|
||||
$observe: function(key, fn) {
|
||||
var attrs = this,
|
||||
@@ -789,7 +789,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
fn(attrs[key]);
|
||||
}
|
||||
});
|
||||
return fn;
|
||||
|
||||
return function() {
|
||||
arrayRemove(listeners, fn);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1649,16 +1652,15 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
|
||||
template = trim(template);
|
||||
if ((type = TABLE_CONTENT_REGEXP.exec(template))) {
|
||||
type = type[1].toLowerCase();
|
||||
var table = jqLite('<table>' + template + '</table>'),
|
||||
tbody = table.children('tbody'),
|
||||
leaf = /(td|th)/.test(type) && table.find('tr');
|
||||
if (tbody.length && type !== 'tbody') {
|
||||
table = tbody;
|
||||
var table = jqLite('<table>' + template + '</table>');
|
||||
if (/(thead|tbody|tfoot)/.test(type)) {
|
||||
return table.children(type);
|
||||
}
|
||||
if (leaf && leaf.length) {
|
||||
table = leaf;
|
||||
table = table.children('tbody');
|
||||
if (type === 'tr') {
|
||||
return table.children('tr');
|
||||
}
|
||||
return table.contents();
|
||||
return table.children('tr').contents();
|
||||
}
|
||||
return jqLite('<div>' +
|
||||
template +
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
* such as selected. (Their presence means true and their absence means false.)
|
||||
* If we put an Angular interpolation expression into such an attribute then the
|
||||
* binding information would be lost when the browser removes the attribute.
|
||||
* The `ngSelected` directive solves this problem for the `selected` atttribute.
|
||||
* The `ngSelected` directive solves this problem for the `selected` attribute.
|
||||
* This complementary directive is not removed by the browser and so provides
|
||||
* a permanent reliable place to store the binding information.
|
||||
*
|
||||
|
||||
@@ -360,8 +360,6 @@ function FormController(element, attrs, $scope, $animate) {
|
||||
</file>
|
||||
</example>
|
||||
*
|
||||
* @param {string=} name Name of the form. If specified, the form controller will be published into
|
||||
* related scope, under this name.
|
||||
*/
|
||||
var formDirectiveFactory = function(isNgForm) {
|
||||
return ['$timeout', function($timeout) {
|
||||
|
||||
+533
-2
@@ -11,6 +11,11 @@
|
||||
var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
|
||||
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i;
|
||||
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/;
|
||||
var DATE_REGEXP = /^(\d{4})-(\d{2})-(\d{2})$/;
|
||||
var DATETIMELOCAL_REGEXP = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d)$/;
|
||||
var WEEK_REGEXP = /^(\d{4})-W(\d\d)$/;
|
||||
var MONTH_REGEXP = /^(\d{4})-(\d\d)$/;
|
||||
var TIME_REGEXP = /^(\d\d):(\d\d)$/;
|
||||
|
||||
var inputType = {
|
||||
|
||||
@@ -91,6 +96,425 @@ var inputType = {
|
||||
*/
|
||||
'text': textInputType,
|
||||
|
||||
/**
|
||||
* @ngdoc input
|
||||
* @name input[date]
|
||||
*
|
||||
* @description
|
||||
* Input with date validation and transformation. In browsers that do not yet support
|
||||
* the HTML5 date input, a text element will be used. In that case, text must be entered in a valid ISO-8601
|
||||
* date format (yyyy-MM-dd), for example: `2009-01-06`. The model must always be a Date object.
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO date string (yyyy-MM-dd).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be
|
||||
* a valid ISO date string (yyyy-MM-dd).
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
* `required` when you want to data-bind to the `required` attribute.
|
||||
* @param {string=} ngChange Angular expression to be executed when input changes due to user
|
||||
* interaction with the input element.
|
||||
*
|
||||
* @example
|
||||
<example name="date-input-directive">
|
||||
<file name="index.html">
|
||||
<script>
|
||||
function Ctrl($scope) {
|
||||
$scope.value = new Date(2013, 9, 22);
|
||||
}
|
||||
</script>
|
||||
<form name="myForm" ng-controller="Ctrl as dateCtrl">
|
||||
Pick a date between in 2013:
|
||||
<input type="date" id="exampleInput" name="input" ng-model="value"
|
||||
placeholder="yyyy-MM-dd" min="2013-01-01" max="2013-12-31" required />
|
||||
<span class="error" ng-show="myForm.input.$error.required">
|
||||
Required!</span>
|
||||
<span class="error" ng-show="myForm.input.$error.date">
|
||||
Not a valid date!</span>
|
||||
<tt>value = {{value | date: "yyyy-MM-dd"}}</tt><br/>
|
||||
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
|
||||
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
|
||||
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
|
||||
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
|
||||
</form>
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
var value = element(by.binding('value | date: "yyyy-MM-dd"'));
|
||||
var valid = element(by.binding('myForm.input.$valid'));
|
||||
var input = element(by.model('value'));
|
||||
|
||||
// currently protractor/webdriver does not support
|
||||
// sending keys to all known HTML5 input controls
|
||||
// for various browsers (see https://github.com/angular/protractor/issues/562).
|
||||
function setInput(val) {
|
||||
// set the value of the element and force validation.
|
||||
var scr = "var ipt = document.getElementById('exampleInput'); " +
|
||||
"ipt.value = '" + val + "';" +
|
||||
"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });";
|
||||
browser.executeScript(scr);
|
||||
}
|
||||
|
||||
it('should initialize to model', function() {
|
||||
expect(value.getText()).toContain('2013-10-22');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = true');
|
||||
});
|
||||
|
||||
it('should be invalid if empty', function() {
|
||||
setInput('');
|
||||
expect(value.getText()).toEqual('value =');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
|
||||
it('should be invalid if over max', function() {
|
||||
setInput('2015-01-01');
|
||||
expect(value.getText()).toContain('');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
</file>
|
||||
</example>f
|
||||
*/
|
||||
'date': createDateInputType('date', DATE_REGEXP,
|
||||
createDateParser(DATE_REGEXP, ['yyyy', 'MM', 'dd']),
|
||||
'yyyy-MM-dd'),
|
||||
|
||||
/**
|
||||
* @ngdoc input
|
||||
* @name input[dateTimeLocal]
|
||||
*
|
||||
* @description
|
||||
* Input with datetime validation and transformation. In browsers that do not yet support
|
||||
* the HTML5 date input, a text element will be used. In that case, the text must be entered in a valid ISO-8601
|
||||
* local datetime format (yyyy-MM-ddTHH:mm), for example: `2010-12-28T14:57`. The model must be a Date object.
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO datetime format (yyyy-MM-ddTHH:mm).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be
|
||||
* a valid ISO datetime format (yyyy-MM-ddTHH:mm).
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
* `required` when you want to data-bind to the `required` attribute.
|
||||
* @param {string=} ngChange Angular expression to be executed when input changes due to user
|
||||
* interaction with the input element.
|
||||
*
|
||||
* @example
|
||||
<example name="datetimelocal-input-directive">
|
||||
<file name="index.html">
|
||||
<script>
|
||||
function Ctrl($scope) {
|
||||
$scope.value = new Date(2010, 11, 28, 14, 57);
|
||||
}
|
||||
</script>
|
||||
<form name="myForm" ng-controller="Ctrl as dateCtrl">
|
||||
Pick a date between in 2013:
|
||||
<input type="datetime-local" id="exampleInput" name="input" ng-model="value"
|
||||
placeholder="yyyy-MM-ddTHH:mm" min="2001-01-01T00:00" max="2013-12-31T00:00" required />
|
||||
<span class="error" ng-show="myForm.input.$error.required">
|
||||
Required!</span>
|
||||
<span class="error" ng-show="myForm.input.$error.datetimelocal">
|
||||
Not a valid date!</span>
|
||||
<tt>value = {{value | date: "yyyy-MM-ddTHH:mm"}}</tt><br/>
|
||||
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
|
||||
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
|
||||
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
|
||||
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
|
||||
</form>
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
var value = element(by.binding('value | date: "yyyy-MM-ddTHH:mm"'));
|
||||
var valid = element(by.binding('myForm.input.$valid'));
|
||||
var input = element(by.model('value'));
|
||||
|
||||
// currently protractor/webdriver does not support
|
||||
// sending keys to all known HTML5 input controls
|
||||
// for various browsers (https://github.com/angular/protractor/issues/562).
|
||||
function setInput(val) {
|
||||
// set the value of the element and force validation.
|
||||
var scr = "var ipt = document.getElementById('exampleInput'); " +
|
||||
"ipt.value = '" + val + "';" +
|
||||
"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });";
|
||||
browser.executeScript(scr);
|
||||
}
|
||||
|
||||
it('should initialize to model', function() {
|
||||
expect(value.getText()).toContain('2010-12-28T14:57');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = true');
|
||||
});
|
||||
|
||||
it('should be invalid if empty', function() {
|
||||
setInput('');
|
||||
expect(value.getText()).toEqual('value =');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
|
||||
it('should be invalid if over max', function() {
|
||||
setInput('2015-01-01T23:59');
|
||||
expect(value.getText()).toContain('');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
'datetime-local': createDateInputType('datetimelocal', DATETIMELOCAL_REGEXP,
|
||||
createDateParser(DATETIMELOCAL_REGEXP, ['yyyy', 'MM', 'dd', 'HH', 'mm']),
|
||||
'yyyy-MM-ddTHH:mm'),
|
||||
|
||||
/**
|
||||
* @ngdoc input
|
||||
* @name input[time]
|
||||
*
|
||||
* @description
|
||||
* Input with time validation and transformation. In browsers that do not yet support
|
||||
* the HTML5 date input, a text element will be used. In that case, the text must be entered in a valid ISO-8601
|
||||
* local time format (HH:mm), for example: `14:57`. Model must be a Date object. This binding will always output a
|
||||
* Date object to the model of January 1, 1900, or local date `new Date(0, 0, 1, HH, mm)`.
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO time format (HH:mm).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be a
|
||||
* valid ISO time format (HH:mm).
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
* `required` when you want to data-bind to the `required` attribute.
|
||||
* @param {string=} ngChange Angular expression to be executed when input changes due to user
|
||||
* interaction with the input element.
|
||||
*
|
||||
* @example
|
||||
<example name="time-input-directive">
|
||||
<file name="index.html">
|
||||
<script>
|
||||
function Ctrl($scope) {
|
||||
$scope.value = new Date(0, 0, 1, 14, 57);
|
||||
}
|
||||
</script>
|
||||
<form name="myForm" ng-controller="Ctrl as dateCtrl">
|
||||
Pick a between 8am and 5pm:
|
||||
<input type="time" id="exampleInput" name="input" ng-model="value"
|
||||
placeholder="HH:mm" min="08:00" max="17:00" required />
|
||||
<span class="error" ng-show="myForm.input.$error.required">
|
||||
Required!</span>
|
||||
<span class="error" ng-show="myForm.input.$error.time">
|
||||
Not a valid date!</span>
|
||||
<tt>value = {{value | date: "HH:mm"}}</tt><br/>
|
||||
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
|
||||
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
|
||||
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
|
||||
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
|
||||
</form>
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
var value = element(by.binding('value | date: "HH:mm"'));
|
||||
var valid = element(by.binding('myForm.input.$valid'));
|
||||
var input = element(by.model('value'));
|
||||
|
||||
// currently protractor/webdriver does not support
|
||||
// sending keys to all known HTML5 input controls
|
||||
// for various browsers (https://github.com/angular/protractor/issues/562).
|
||||
function setInput(val) {
|
||||
// set the value of the element and force validation.
|
||||
var scr = "var ipt = document.getElementById('exampleInput'); " +
|
||||
"ipt.value = '" + val + "';" +
|
||||
"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });";
|
||||
browser.executeScript(scr);
|
||||
}
|
||||
|
||||
it('should initialize to model', function() {
|
||||
expect(value.getText()).toContain('14:57');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = true');
|
||||
});
|
||||
|
||||
it('should be invalid if empty', function() {
|
||||
setInput('');
|
||||
expect(value.getText()).toEqual('value =');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
|
||||
it('should be invalid if over max', function() {
|
||||
setInput('23:59');
|
||||
expect(value.getText()).toContain('');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
'time': createDateInputType('time', TIME_REGEXP,
|
||||
createDateParser(TIME_REGEXP, ['HH', 'mm']),
|
||||
'HH:mm'),
|
||||
|
||||
/**
|
||||
* @ngdoc input
|
||||
* @name input[week]
|
||||
*
|
||||
* @description
|
||||
* Input with week-of-the-year validation and transformation to Date. In browsers that do not yet support
|
||||
* the HTML5 week input, a text element will be used. In that case, the text must be entered in a valid ISO-8601
|
||||
* week format (yyyy-W##), for example: `2013-W02`. The model must always be a Date object.
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be a
|
||||
* valid ISO week format (yyyy-W##).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must be
|
||||
* a valid ISO week format (yyyy-W##).
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
* `required` when you want to data-bind to the `required` attribute.
|
||||
* @param {string=} ngChange Angular expression to be executed when input changes due to user
|
||||
* interaction with the input element.
|
||||
*
|
||||
* @example
|
||||
<example name="week-input-directive">
|
||||
<file name="index.html">
|
||||
<script>
|
||||
function Ctrl($scope) {
|
||||
$scope.value = new Date(2013, 0, 3);
|
||||
}
|
||||
</script>
|
||||
<form name="myForm" ng-controller="Ctrl as dateCtrl">
|
||||
Pick a date between in 2013:
|
||||
<input id="exampleInput" type="week" name="input" ng-model="value"
|
||||
placeholder="YYYY-W##" min="2012-W32" max="2013-W52" required />
|
||||
<span class="error" ng-show="myForm.input.$error.required">
|
||||
Required!</span>
|
||||
<span class="error" ng-show="myForm.input.$error.week">
|
||||
Not a valid date!</span>
|
||||
<tt>value = {{value | date: "yyyy-Www"}}</tt><br/>
|
||||
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
|
||||
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
|
||||
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
|
||||
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
|
||||
</form>
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
var value = element(by.binding('value | date: "yyyy-Www"'));
|
||||
var valid = element(by.binding('myForm.input.$valid'));
|
||||
var input = element(by.model('value'));
|
||||
|
||||
// currently protractor/webdriver does not support
|
||||
// sending keys to all known HTML5 input controls
|
||||
// for various browsers (https://github.com/angular/protractor/issues/562).
|
||||
function setInput(val) {
|
||||
// set the value of the element and force validation.
|
||||
var scr = "var ipt = document.getElementById('exampleInput'); " +
|
||||
"ipt.value = '" + val + "';" +
|
||||
"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });";
|
||||
browser.executeScript(scr);
|
||||
}
|
||||
|
||||
it('should initialize to model', function() {
|
||||
expect(value.getText()).toContain('2013-W01');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = true');
|
||||
});
|
||||
|
||||
it('should be invalid if empty', function() {
|
||||
setInput('');
|
||||
expect(value.getText()).toEqual('value =');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
|
||||
it('should be invalid if over max', function() {
|
||||
setInput('2015-W01');
|
||||
expect(value.getText()).toContain('');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
'week': createDateInputType('week', WEEK_REGEXP, weekParser, 'yyyy-Www'),
|
||||
|
||||
/**
|
||||
* @ngdoc input
|
||||
* @name input[month]
|
||||
*
|
||||
* @description
|
||||
* Input with month validation and transformation. In browsers that do not yet support
|
||||
* the HTML5 month input, a text element will be used. In that case, the text must be entered in a valid ISO-8601
|
||||
* month format (yyyy-MM), for example: `2009-01`. The model must always be a Date object. In the event the model is
|
||||
* not set to the first of the month, the first of that model's month is assumed.
|
||||
*
|
||||
* @param {string} ngModel Assignable angular expression to data-bind to.
|
||||
* @param {string=} name Property name of the form under which the control is published.
|
||||
* @param {string=} min Sets the `min` validation error key if the value entered is less than `min`. This must be
|
||||
* a valid ISO month format (yyyy-MM).
|
||||
* @param {string=} max Sets the `max` validation error key if the value entered is greater than `max`. This must
|
||||
* be a valid ISO month format (yyyy-MM).
|
||||
* @param {string=} required Sets `required` validation error key if the value is not entered.
|
||||
* @param {string=} ngRequired Adds `required` attribute and `required` validation constraint to
|
||||
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
|
||||
* `required` when you want to data-bind to the `required` attribute.
|
||||
* @param {string=} ngChange Angular expression to be executed when input changes due to user
|
||||
* interaction with the input element.
|
||||
*
|
||||
* @example
|
||||
<example name="month-input-directive">
|
||||
<file name="index.html">
|
||||
<script>
|
||||
function Ctrl($scope) {
|
||||
$scope.value = new Date(2013, 9, 1);
|
||||
}
|
||||
</script>
|
||||
<form name="myForm" ng-controller="Ctrl as dateCtrl">
|
||||
Pick a month int 2013:
|
||||
<input id="exampleInput" type="month" name="input" ng-model="value"
|
||||
placeholder="yyyy-MM" min="2013-01" max="2013-12" required />
|
||||
<span class="error" ng-show="myForm.input.$error.required">
|
||||
Required!</span>
|
||||
<span class="error" ng-show="myForm.input.$error.month">
|
||||
Not a valid month!</span>
|
||||
<tt>value = {{value | date: "yyyy-MM"}}</tt><br/>
|
||||
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
|
||||
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
|
||||
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
|
||||
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
|
||||
</form>
|
||||
</file>
|
||||
<file name="protractor.js" type="protractor">
|
||||
var value = element(by.binding('value | date: "yyyy-MM"'));
|
||||
var valid = element(by.binding('myForm.input.$valid'));
|
||||
var input = element(by.model('value'));
|
||||
|
||||
// currently protractor/webdriver does not support
|
||||
// sending keys to all known HTML5 input controls
|
||||
// for various browsers (https://github.com/angular/protractor/issues/562).
|
||||
function setInput(val) {
|
||||
// set the value of the element and force validation.
|
||||
var scr = "var ipt = document.getElementById('exampleInput'); " +
|
||||
"ipt.value = '" + val + "';" +
|
||||
"angular.element(ipt).scope().$apply(function(s) { s.myForm[ipt.name].$setViewValue('" + val + "'); });";
|
||||
browser.executeScript(scr);
|
||||
}
|
||||
|
||||
it('should initialize to model', function() {
|
||||
expect(value.getText()).toContain('2013-10');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = true');
|
||||
});
|
||||
|
||||
it('should be invalid if empty', function() {
|
||||
setInput('');
|
||||
expect(value.getText()).toEqual('value =');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
|
||||
it('should be invalid if over max', function() {
|
||||
setInput('2015-01');
|
||||
expect(value.getText()).toContain('');
|
||||
expect(valid.getText()).toContain('myForm.input.$valid = false');
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
'month': createDateInputType('month', MONTH_REGEXP,
|
||||
createDateParser(MONTH_REGEXP, ['yyyy', 'MM']),
|
||||
'yyyy-MM'),
|
||||
|
||||
/**
|
||||
* @ngdoc input
|
||||
@@ -593,6 +1017,108 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
|
||||
}
|
||||
}
|
||||
|
||||
function weekParser(isoWeek) {
|
||||
if(isDate(isoWeek)) {
|
||||
return isoWeek;
|
||||
}
|
||||
|
||||
if(isString(isoWeek)) {
|
||||
WEEK_REGEXP.lastIndex = 0;
|
||||
var parts = WEEK_REGEXP.exec(isoWeek);
|
||||
if(parts) {
|
||||
var year = +parts[1],
|
||||
week = +parts[2],
|
||||
firstThurs = getFirstThursdayOfYear(year),
|
||||
addDays = (week - 1) * 7;
|
||||
return new Date(year, 0, firstThurs.getDate() + addDays);
|
||||
}
|
||||
}
|
||||
|
||||
return NaN;
|
||||
}
|
||||
|
||||
function createDateParser(regexp, mapping) {
|
||||
return function(iso) {
|
||||
var parts, map;
|
||||
|
||||
if(isDate(iso)) {
|
||||
return iso;
|
||||
}
|
||||
|
||||
if(isString(iso)) {
|
||||
regexp.lastIndex = 0;
|
||||
parts = regexp.exec(iso);
|
||||
|
||||
if(parts) {
|
||||
parts.shift();
|
||||
map = { yyyy: 0, MM: 1, dd: 1, HH: 0, mm: 0 };
|
||||
|
||||
forEach(parts, function(part, index) {
|
||||
if(index < mapping.length) {
|
||||
map[mapping[index]] = +part;
|
||||
}
|
||||
});
|
||||
|
||||
return new Date(map.yyyy, map.MM - 1, map.dd, map.HH, map.mm);
|
||||
}
|
||||
}
|
||||
|
||||
return NaN;
|
||||
};
|
||||
}
|
||||
|
||||
function createDateInputType(type, regexp, parseDate, format) {
|
||||
return function dynamicDateInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter) {
|
||||
textInputType(scope, element, attr, ctrl, $sniffer, $browser);
|
||||
|
||||
ctrl.$parsers.push(function(value) {
|
||||
if(ctrl.$isEmpty(value)) {
|
||||
ctrl.$setValidity(type, true);
|
||||
return null;
|
||||
}
|
||||
|
||||
if(regexp.test(value)) {
|
||||
ctrl.$setValidity(type, true);
|
||||
return parseDate(value);
|
||||
}
|
||||
|
||||
ctrl.$setValidity(type, false);
|
||||
return undefined;
|
||||
});
|
||||
|
||||
ctrl.$formatters.push(function(value) {
|
||||
if(isDate(value)) {
|
||||
return $filter('date')(value, format);
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
if(attr.min) {
|
||||
var minValidator = function(value) {
|
||||
var valid = ctrl.$isEmpty(value) ||
|
||||
(parseDate(value) >= parseDate(attr.min));
|
||||
ctrl.$setValidity('min', valid);
|
||||
return valid ? value : undefined;
|
||||
};
|
||||
|
||||
ctrl.$parsers.push(minValidator);
|
||||
ctrl.$formatters.push(minValidator);
|
||||
}
|
||||
|
||||
if(attr.max) {
|
||||
var maxValidator = function(value) {
|
||||
var valid = ctrl.$isEmpty(value) ||
|
||||
(parseDate(value) <= parseDate(attr.max));
|
||||
ctrl.$setValidity('max', valid);
|
||||
return valid ? value : undefined;
|
||||
};
|
||||
|
||||
ctrl.$parsers.push(maxValidator);
|
||||
ctrl.$formatters.push(maxValidator);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
|
||||
textInputType(scope, element, attr, ctrl, $sniffer, $browser);
|
||||
|
||||
@@ -852,14 +1378,14 @@ function checkboxInputType(scope, element, attr, ctrl) {
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
var inputDirective = ['$browser', '$sniffer', function($browser, $sniffer) {
|
||||
var inputDirective = ['$browser', '$sniffer', '$filter', function($browser, $sniffer, $filter) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
require: '?ngModel',
|
||||
link: function(scope, element, attr, ctrl) {
|
||||
if (ctrl) {
|
||||
(inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrl, $sniffer,
|
||||
$browser);
|
||||
$browser, $filter);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1247,6 +1773,11 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
||||
* - {@link input[number] number}
|
||||
* - {@link input[email] email}
|
||||
* - {@link input[url] url}
|
||||
* - {@link input[date] date}
|
||||
* - {@link input[dateTimeLocal] dateTimeLocal}
|
||||
* - {@link input[time] time}
|
||||
* - {@link input[month] month}
|
||||
* - {@link input[week] week}
|
||||
* - {@link ng.directive:select select}
|
||||
* - {@link ng.directive:textarea textarea}
|
||||
*
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* Typically, you don't use `ngBind` directly, but instead you use the double curly markup like
|
||||
* `{{ expression }}` which is similar but less verbose.
|
||||
*
|
||||
* It is preferrable to use `ngBind` instead of `{{ expression }}` when a template is momentarily
|
||||
* It is preferable to use `ngBind` instead of `{{ expression }}` when a template is momentarily
|
||||
* displayed by the browser in its raw state before Angular compiles it. Since `ngBind` is an
|
||||
* element attribute, it makes the bindings invisible to the user while the page is loading.
|
||||
*
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
* @priority 400
|
||||
*
|
||||
* @param {string} ngInclude|src angular expression evaluating to URL. If the source is a string constant,
|
||||
* make sure you wrap it in quotes, e.g. `src="'myPartialTemplate.html'"`.
|
||||
* make sure you wrap it in **single** quotes, e.g. `src="'myPartialTemplate.html'"`.
|
||||
* @param {string=} onload Expression to evaluate when a new partial is loaded.
|
||||
*
|
||||
* @param {string=} autoscroll Whether `ngInclude` should call {@link ng.$anchorScroll
|
||||
@@ -146,7 +146,6 @@
|
||||
/**
|
||||
* @ngdoc event
|
||||
* @name ngInclude#$includeContentRequested
|
||||
* @eventOf ng.directive:ngInclude
|
||||
* @eventType emit on the scope ngInclude was declared in
|
||||
* @description
|
||||
* Emitted every time the ngInclude content is requested.
|
||||
@@ -156,7 +155,6 @@
|
||||
/**
|
||||
* @ngdoc event
|
||||
* @name ngInclude#$includeContentLoaded
|
||||
* @eventOf ng.directive:ngInclude
|
||||
* @eventType emit on the current ngInclude scope
|
||||
* @description
|
||||
* Emitted every time the ngInclude content is reloaded.
|
||||
|
||||
@@ -68,9 +68,11 @@
|
||||
* as **data-ng-repeat-start**, **x-ng-repeat-start** and **ng:repeat-start**).
|
||||
*
|
||||
* @animations
|
||||
* enter - when a new item is added to the list or when an item is revealed after a filter
|
||||
* leave - when an item is removed from the list or when an item is filtered out
|
||||
* move - when an adjacent item is filtered out causing a reorder or when the item contents are reordered
|
||||
* **.enter** - when a new item is added to the list or when an item is revealed after a filter
|
||||
*
|
||||
* **.leave** - when an item is removed from the list or when an item is filtered out
|
||||
*
|
||||
* **.move** - when an adjacent item is filtered out causing a reorder or when the item contents are reordered
|
||||
*
|
||||
* @element ANY
|
||||
* @scope
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
* @scope
|
||||
* @priority 800
|
||||
* @param {*} ngSwitch|on expression to match against <tt>ng-switch-when</tt>.
|
||||
* @paramDescription
|
||||
* On child elements add:
|
||||
*
|
||||
* * `ngSwitchWhen`: the case statement to match against. If match then this
|
||||
|
||||
@@ -394,6 +394,12 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
value = valueFn(scope, locals);
|
||||
}
|
||||
}
|
||||
// Update the null option's selected property here so $render cleans it up correctly
|
||||
if (optionGroupsCache[0].length > 1) {
|
||||
if (optionGroupsCache[0][1].id !== key) {
|
||||
optionGroupsCache[0][1].selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
ctrl.$setViewValue(value);
|
||||
});
|
||||
@@ -531,7 +537,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
||||
lastElement.val(existingOption.id = option.id);
|
||||
}
|
||||
// lastElement.prop('selected') provided by jQuery has side-effects
|
||||
if (lastElement[0].selected !== option.selected) {
|
||||
if (existingOption.selected !== option.selected) {
|
||||
lastElement.prop('selected', (existingOption.selected = option.selected));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
var styleDirective = valueFn({
|
||||
restrict: 'E',
|
||||
terminal: true
|
||||
terminal: false
|
||||
});
|
||||
|
||||
@@ -7,6 +7,22 @@
|
||||
*
|
||||
* @description
|
||||
* A {@link angular.element jQuery or jqLite} wrapper for the browser's `window.document` object.
|
||||
*
|
||||
* @example
|
||||
<example>
|
||||
<file name="index.html">
|
||||
<div ng-controller="MainCtrl">
|
||||
<p>$document title: <b ng-bind="title"></b></p>
|
||||
<p>window.document title: <b ng-bind="windowTitle"></b></p>
|
||||
</div>
|
||||
</file>
|
||||
<file name="script.js">
|
||||
function MainCtrl($scope, $document) {
|
||||
$scope.title = $document[0].title;
|
||||
$scope.windowTitle = angular.element(window.document)[0].title;
|
||||
}
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
function $DocumentProvider(){
|
||||
this.$get = ['$window', function(window){
|
||||
|
||||
@@ -235,6 +235,32 @@ function timeZoneGetter(date) {
|
||||
return paddedZone;
|
||||
}
|
||||
|
||||
function getFirstThursdayOfYear(year) {
|
||||
// 0 = index of January
|
||||
var dayOfWeekOnFirst = (new Date(year, 0, 1)).getDay();
|
||||
// 4 = index of Thursday (+1 to account for 1st = 5)
|
||||
// 11 = index of *next* Thursday (+1 account for 1st = 12)
|
||||
return new Date(year, 0, ((dayOfWeekOnFirst <= 4) ? 5 : 12) - dayOfWeekOnFirst);
|
||||
}
|
||||
|
||||
function getThursdayThisWeek(datetime) {
|
||||
return new Date(datetime.getFullYear(), datetime.getMonth(),
|
||||
// 4 = index of Thursday
|
||||
datetime.getDate() + (4 - datetime.getDay()));
|
||||
}
|
||||
|
||||
function weekGetter(size) {
|
||||
return function(date) {
|
||||
var firstThurs = getFirstThursdayOfYear(date.getFullYear()),
|
||||
thisThurs = getThursdayThisWeek(date);
|
||||
|
||||
var diff = +thisThurs - +firstThurs,
|
||||
result = 1 + Math.round(diff / 6.048e8); // 6.048e8 ms per week
|
||||
|
||||
return padNumber(result, size);
|
||||
};
|
||||
}
|
||||
|
||||
function ampmGetter(date, formats) {
|
||||
return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1];
|
||||
}
|
||||
@@ -263,10 +289,12 @@ var DATE_FORMATS = {
|
||||
EEEE: dateStrGetter('Day'),
|
||||
EEE: dateStrGetter('Day', true),
|
||||
a: ampmGetter,
|
||||
Z: timeZoneGetter
|
||||
Z: timeZoneGetter,
|
||||
ww: weekGetter(2),
|
||||
w: weekGetter(1)
|
||||
};
|
||||
|
||||
var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,
|
||||
var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZEw']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z|w+))(.*)/,
|
||||
NUMBER_STRING = /^\-?\d+$/;
|
||||
|
||||
/**
|
||||
@@ -301,6 +329,8 @@ var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+
|
||||
* * `'.sss' or ',sss'`: Millisecond in second, padded (000-999)
|
||||
* * `'a'`: am/pm marker
|
||||
* * `'Z'`: 4 digit (+sign) representation of the timezone offset (-1200-+1200)
|
||||
* * `'ww'`: ISO-8601 week of year (00-53)
|
||||
* * `'w'`: ISO-8601 week of year (0-53)
|
||||
*
|
||||
* `format` string can also be one of the following predefined
|
||||
* {@link guide/i18n localizable formats}:
|
||||
@@ -441,7 +471,7 @@ function dateFilter($locale) {
|
||||
* @returns {string} JSON string.
|
||||
*
|
||||
*
|
||||
* @example:
|
||||
* @example
|
||||
<example>
|
||||
<file name="index.html">
|
||||
<pre>{{ {'name':'value'} | json }}</pre>
|
||||
|
||||
@@ -74,6 +74,12 @@ function orderByFilter($parse){
|
||||
predicate = predicate.substring(1);
|
||||
}
|
||||
get = $parse(predicate);
|
||||
if (get.constant) {
|
||||
var key = get();
|
||||
return reverseComparator(function(a,b) {
|
||||
return compare(a[key], b[key]);
|
||||
}, descending);
|
||||
}
|
||||
}
|
||||
return reverseComparator(function(a,b){
|
||||
return compare(get(a),get(b));
|
||||
|
||||
+3
-4
@@ -103,7 +103,7 @@ function $HttpProvider() {
|
||||
|
||||
// transform outgoing request data
|
||||
transformRequest: [function(d) {
|
||||
return isObject(d) && !isFile(d) ? toJson(d) : d;
|
||||
return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d;
|
||||
}],
|
||||
|
||||
// default headers
|
||||
@@ -236,9 +236,8 @@ function $HttpProvider() {
|
||||
*
|
||||
* # Shortcut methods
|
||||
*
|
||||
* Since all invocations of the $http service require passing in an HTTP method and URL, and
|
||||
* POST/PUT requests require request data to be provided as well, shortcut methods
|
||||
* were created:
|
||||
* Shortcut methods are also available. All shortcut methods require passing in the URL, and
|
||||
* request data must be passed in for POST/PUT requests.
|
||||
*
|
||||
* ```js
|
||||
* $http.get('/someUrl').success(successCallback);
|
||||
|
||||
+35
-30
@@ -49,16 +49,13 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
|
||||
var callbackId = '_' + (callbacks.counter++).toString(36);
|
||||
callbacks[callbackId] = function(data) {
|
||||
callbacks[callbackId].data = data;
|
||||
callbacks[callbackId].called = true;
|
||||
};
|
||||
|
||||
var jsonpDone = jsonpReq(url.replace('JSON_CALLBACK', 'angular.callbacks.' + callbackId),
|
||||
function() {
|
||||
if (callbacks[callbackId].data) {
|
||||
completeRequest(callback, 200, callbacks[callbackId].data);
|
||||
} else {
|
||||
completeRequest(callback, status || -2);
|
||||
}
|
||||
callbacks[callbackId] = angular.noop;
|
||||
callbackId, function(status, text) {
|
||||
completeRequest(callback, status, callbacks[callbackId].data, "", text);
|
||||
callbacks[callbackId] = noop;
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -144,9 +141,11 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
|
||||
jsonpDone = xhr = null;
|
||||
|
||||
// fix status code when it is 0 (0 status is undocumented).
|
||||
// Occurs when accessing file resources.
|
||||
// On Android 4.1 stock browser it occurs while retrieving files from application cache.
|
||||
status = (status === 0) ? (response ? 200 : 404) : status;
|
||||
// Occurs when accessing file resources or on Android 4.1 stock browser
|
||||
// while retrieving files from application cache.
|
||||
if (status === 0) {
|
||||
status = response ? 200 : urlResolve(url).protocol == 'file' ? 404 : 0;
|
||||
}
|
||||
|
||||
// normalize IE bug (http://bugs.jquery.com/ticket/1450)
|
||||
status = status == 1223 ? 204 : status;
|
||||
@@ -156,33 +155,39 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
|
||||
}
|
||||
};
|
||||
|
||||
function jsonpReq(url, done) {
|
||||
function jsonpReq(url, callbackId, done) {
|
||||
// we can't use jQuery/jqLite here because jQuery does crazy shit with script elements, e.g.:
|
||||
// - fetches local scripts via XHR and evals them
|
||||
// - adds and immediately removes script elements from the document
|
||||
var script = rawDocument.createElement('script'),
|
||||
doneWrapper = function() {
|
||||
script.onreadystatechange = script.onload = script.onerror = null;
|
||||
rawDocument.body.removeChild(script);
|
||||
if (done) done();
|
||||
};
|
||||
|
||||
script.type = 'text/javascript';
|
||||
var script = rawDocument.createElement('script'), callback = null;
|
||||
script.type = "text/javascript";
|
||||
script.src = url;
|
||||
script.async = true;
|
||||
|
||||
if (msie && msie <= 8) {
|
||||
script.onreadystatechange = function() {
|
||||
if (/loaded|complete/.test(script.readyState)) {
|
||||
doneWrapper();
|
||||
callback = function(event) {
|
||||
removeEventListenerFn(script, "load", callback);
|
||||
removeEventListenerFn(script, "error", callback);
|
||||
rawDocument.body.removeChild(script);
|
||||
script = null;
|
||||
var status = -1;
|
||||
var text = "unknown";
|
||||
|
||||
if (event) {
|
||||
if (event.type === "load" && !callbacks[callbackId].called) {
|
||||
event = { type: "error" };
|
||||
}
|
||||
};
|
||||
} else {
|
||||
script.onload = script.onerror = function() {
|
||||
doneWrapper();
|
||||
};
|
||||
}
|
||||
text = event.type;
|
||||
status = event.type === "error" ? 404 : 200;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
done(status, text);
|
||||
}
|
||||
};
|
||||
|
||||
addEventListenerFn(script, "load", callback);
|
||||
addEventListenerFn(script, "error", callback);
|
||||
rawDocument.body.appendChild(script);
|
||||
return doneWrapper;
|
||||
return callback;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@
|
||||
*
|
||||
* Because `finally` is a reserved word in JavaScript and reserved keywords are not supported as
|
||||
* property names by ES3, you'll need to invoke the method like `promise['finally'](callback)` to
|
||||
* make your code IE8 compatible.
|
||||
* make your code IE8 and Android 2.x compatible.
|
||||
*
|
||||
* # Chaining promises
|
||||
*
|
||||
|
||||
+21
-10
@@ -1,21 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
function $$RAFProvider(){ //rAF
|
||||
this.$get = ['$window', function($window) {
|
||||
this.$get = ['$window', '$timeout', function($window, $timeout) {
|
||||
var requestAnimationFrame = $window.requestAnimationFrame ||
|
||||
$window.webkitRequestAnimationFrame;
|
||||
$window.webkitRequestAnimationFrame ||
|
||||
$window.mozRequestAnimationFrame;
|
||||
|
||||
var cancelAnimationFrame = $window.cancelAnimationFrame ||
|
||||
$window.webkitCancelAnimationFrame;
|
||||
$window.webkitCancelAnimationFrame ||
|
||||
$window.mozCancelAnimationFrame ||
|
||||
$window.webkitCancelRequestAnimationFrame;
|
||||
|
||||
var raf = function(fn) {
|
||||
var id = requestAnimationFrame(fn);
|
||||
return function() {
|
||||
cancelAnimationFrame(id);
|
||||
};
|
||||
};
|
||||
var rafSupported = !!requestAnimationFrame;
|
||||
var raf = rafSupported
|
||||
? function(fn) {
|
||||
var id = requestAnimationFrame(fn);
|
||||
return function() {
|
||||
cancelAnimationFrame(id);
|
||||
};
|
||||
}
|
||||
: function(fn) {
|
||||
var timer = $timeout(fn, 16.66, false); // 1000 / 60 = 16.666
|
||||
return function() {
|
||||
$timeout.cancel(timer);
|
||||
};
|
||||
};
|
||||
|
||||
raf.supported = !!requestAnimationFrame;
|
||||
raf.supported = rafSupported;
|
||||
|
||||
return raf;
|
||||
}];
|
||||
|
||||
+46
-11
@@ -139,7 +139,6 @@ function $RootScopeProvider(){
|
||||
/**
|
||||
* @ngdoc property
|
||||
* @name $rootScope.Scope#$id
|
||||
* @propertyOf ng.$rootScope.Scope
|
||||
* @returns {number} Unique scope ID (monotonically increasing alphanumeric sequence) useful for
|
||||
* debugging.
|
||||
*/
|
||||
@@ -399,30 +398,40 @@ function $RootScopeProvider(){
|
||||
* {@link ng.$rootScope.Scope#$digest $digest} cycle. Any shallow change within the
|
||||
* collection will trigger a call to the `listener`.
|
||||
*
|
||||
* @param {function(newCollection, oldCollection, scope)} listener a callback function that is
|
||||
* fired with both the `newCollection` and `oldCollection` as parameters.
|
||||
* The `newCollection` object is the newly modified data obtained from the `obj` expression
|
||||
* and the `oldCollection` object is a copy of the former collection data.
|
||||
* The `scope` refers to the current scope.
|
||||
* @param {function(newCollection, oldCollection, scope)} listener a callback function called
|
||||
* when a change is detected.
|
||||
* - The `newCollection` object is the newly modified data obtained from the `obj` expression
|
||||
* - The `oldCollection` object is a copy of the former collection data.
|
||||
* Due to performance considerations, the`oldCollection` value is computed only if the
|
||||
* `listener` function declares two or more arguments.
|
||||
* - The `scope` argument refers to the current scope.
|
||||
*
|
||||
* @returns {function()} Returns a de-registration function for this listener. When the
|
||||
* de-registration function is executed, the internal watch operation is terminated.
|
||||
*/
|
||||
$watchCollection: function(obj, listener) {
|
||||
var self = this;
|
||||
var oldValue;
|
||||
// the current value, updated on each dirty-check run
|
||||
var newValue;
|
||||
// a shallow copy of the newValue from the last dirty-check run,
|
||||
// updated to match newValue during dirty-check run
|
||||
var oldValue;
|
||||
// a shallow copy of the newValue from when the last change happened
|
||||
var veryOldValue;
|
||||
// only track veryOldValue if the listener is asking for it
|
||||
var trackVeryOldValue = (listener.length > 1);
|
||||
var changeDetected = 0;
|
||||
var objGetter = $parse(obj);
|
||||
var internalArray = [];
|
||||
var internalObject = {};
|
||||
var initRun = true;
|
||||
var oldLength = 0;
|
||||
|
||||
function $watchCollectionWatch() {
|
||||
newValue = objGetter(self);
|
||||
var newLength, key;
|
||||
|
||||
if (!isObject(newValue)) {
|
||||
if (!isObject(newValue)) { // if primitive
|
||||
if (oldValue !== newValue) {
|
||||
oldValue = newValue;
|
||||
changeDetected++;
|
||||
@@ -444,7 +453,9 @@ function $RootScopeProvider(){
|
||||
}
|
||||
// copy the items to oldValue and look for changes.
|
||||
for (var i = 0; i < newLength; i++) {
|
||||
if (oldValue[i] !== newValue[i]) {
|
||||
var bothNaN = (oldValue[i] !== oldValue[i]) &&
|
||||
(newValue[i] !== newValue[i]);
|
||||
if (!bothNaN && (oldValue[i] !== newValue[i])) {
|
||||
changeDetected++;
|
||||
oldValue[i] = newValue[i];
|
||||
}
|
||||
@@ -488,7 +499,32 @@ function $RootScopeProvider(){
|
||||
}
|
||||
|
||||
function $watchCollectionAction() {
|
||||
listener(newValue, oldValue, self);
|
||||
if (initRun) {
|
||||
initRun = false;
|
||||
listener(newValue, newValue, self);
|
||||
} else {
|
||||
listener(newValue, veryOldValue, self);
|
||||
}
|
||||
|
||||
// make a copy for the next time a collection is changed
|
||||
if (trackVeryOldValue) {
|
||||
if (!isObject(newValue)) {
|
||||
//primitive
|
||||
veryOldValue = newValue;
|
||||
} else if (isArrayLike(newValue)) {
|
||||
veryOldValue = new Array(newValue.length);
|
||||
for (var i = 0; i < newValue.length; i++) {
|
||||
veryOldValue[i] = newValue[i];
|
||||
}
|
||||
} else { // if object
|
||||
veryOldValue = {};
|
||||
for (var key in newValue) {
|
||||
if (hasOwnProperty.call(newValue, key)) {
|
||||
veryOldValue[key] = newValue[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$watch($watchCollectionWatch, $watchCollectionAction);
|
||||
@@ -652,7 +688,6 @@ function $RootScopeProvider(){
|
||||
/**
|
||||
* @ngdoc event
|
||||
* @name $rootScope.Scope#$destroy
|
||||
* @eventOf ng.$rootScope.Scope
|
||||
* @eventType broadcast on scope being destroyed
|
||||
*
|
||||
* @description
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
function $$SanitizeUriProvider() {
|
||||
var aHrefSanitizationWhitelist = /^\s*(https?|ftp|mailto|tel|file):/,
|
||||
imgSrcSanitizationWhitelist = /^\s*(https?|ftp|file):|data:image\//;
|
||||
imgSrcSanitizationWhitelist = /^\s*(https?|ftp|file|blob):|data:image\//;
|
||||
|
||||
/**
|
||||
* @description
|
||||
|
||||
+1
-1
@@ -521,7 +521,7 @@ function $SceDelegateProvider() {
|
||||
* |---------------------|----------------|
|
||||
* | `$sce.HTML` | For HTML that's safe to source into the application. The {@link ng.directive:ngBindHtml ngBindHtml} directive uses this context for bindings. |
|
||||
* | `$sce.CSS` | For CSS that's safe to source into the application. Currently unused. Feel free to use it in your own directives. |
|
||||
* | `$sce.URL` | For URLs that are safe to follow as links. Currently unused (`<a href=` and `<img src=` sanitize their urls and don't consititute an SCE context. |
|
||||
* | `$sce.URL` | For URLs that are safe to follow as links. Currently unused (`<a href=` and `<img src=` sanitize their urls and don't constitute an SCE context. |
|
||||
* | `$sce.RESOURCE_URL` | For URLs that are not only safe to follow as links, but whose contens are also safe to include in your application. Examples include `ng-include`, `src` / `ngSrc` bindings for tags other than `IMG` (e.g. `IFRAME`, `OBJECT`, etc.) <br><br>Note that `$sce.RESOURCE_URL` makes a stronger statement about the URL than `$sce.URL` does and therefore contexts requiring values trusted for `$sce.RESOURCE_URL` can be used anywhere that values trusted for `$sce.URL` are required. |
|
||||
* | `$sce.JS` | For JavaScript that is safe to execute in your application's context. Currently unused. Feel free to use it in your own directives. |
|
||||
*
|
||||
|
||||
@@ -701,8 +701,7 @@ angular.module('ngAnimate', ['ng'])
|
||||
/**
|
||||
*
|
||||
* @ngdoc function
|
||||
* @name ng.$animate#setClass
|
||||
* @methodOf ng.$animate
|
||||
* @name $animate#setClass
|
||||
* @function
|
||||
* @description Adds and/or removes the given CSS classes to and from the element.
|
||||
* Once complete, the done() callback will be fired (if provided).
|
||||
@@ -771,7 +770,7 @@ angular.module('ngAnimate', ['ng'])
|
||||
fireDOMOperation();
|
||||
fireBeforeCallbackAsync();
|
||||
fireAfterCallbackAsync();
|
||||
fireDoneCallbackAsync();
|
||||
closeAnimation();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -950,7 +949,7 @@ angular.module('ngAnimate', ['ng'])
|
||||
animation, but class-based animations don't. An example of this
|
||||
failing would be when a parent HTML tag has a ng-class attribute
|
||||
causing ALL directives below to skip animations during the digest */
|
||||
if(runner.isClassBased) {
|
||||
if(runner && runner.isClassBased) {
|
||||
cleanup(element, className);
|
||||
} else {
|
||||
$$asyncCallback(function() {
|
||||
|
||||
@@ -25,8 +25,9 @@ angular.module('ngCookies', ['ng']).
|
||||
* @description
|
||||
* Provides read/write access to browser's cookies.
|
||||
*
|
||||
* Only a simple Object is exposed and by adding or removing properties to/from
|
||||
* this object, new cookies are created/deleted at the end of current $eval.
|
||||
* Only a simple Object is exposed and by adding or removing properties to/from this object, new
|
||||
* cookies are created/deleted at the end of current $eval.
|
||||
* The object's properties can only be strings.
|
||||
*
|
||||
* Requires the {@link ngCookies `ngCookies`} module to be installed.
|
||||
*
|
||||
@@ -94,12 +95,10 @@ angular.module('ngCookies', ['ng']).
|
||||
for(name in cookies) {
|
||||
value = cookies[name];
|
||||
if (!angular.isString(value)) {
|
||||
if (angular.isDefined(lastCookies[name])) {
|
||||
cookies[name] = lastCookies[name];
|
||||
} else {
|
||||
delete cookies[name];
|
||||
}
|
||||
} else if (value !== lastCookies[name]) {
|
||||
value = '' + value;
|
||||
cookies[name] = value;
|
||||
}
|
||||
if (value !== lastCookies[name]) {
|
||||
$browser.cookies(name, value);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
Vendored
+49
-25
@@ -1178,7 +1178,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* Creates a new backend definition.
|
||||
*
|
||||
* @param {string} method HTTP method.
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
|
||||
* data string and returns true if the data is as expected.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
|
||||
@@ -1216,7 +1217,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new backend definition for GET requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled.
|
||||
@@ -1228,7 +1230,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new backend definition for HEAD requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled.
|
||||
@@ -1240,7 +1243,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new backend definition for DELETE requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled.
|
||||
@@ -1252,7 +1256,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new backend definition for POST requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
|
||||
* data string and returns true if the data is as expected.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
@@ -1266,7 +1271,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new backend definition for PUT requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
|
||||
* data string and returns true if the data is as expected.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
@@ -1280,7 +1286,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new backend definition for JSONP requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled.
|
||||
*/
|
||||
@@ -1294,7 +1301,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* Creates a new request expectation.
|
||||
*
|
||||
* @param {string} method HTTP method.
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
|
||||
* receives data string and returns true if the data is as expected, or Object if request body
|
||||
* is in JSON format.
|
||||
@@ -1326,7 +1334,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new request expectation for GET requests. For more info see `expect()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {Object=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled. See #expect for more info.
|
||||
@@ -1338,7 +1347,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new request expectation for HEAD requests. For more info see `expect()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {Object=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled.
|
||||
@@ -1350,7 +1360,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new request expectation for DELETE requests. For more info see `expect()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {Object=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled.
|
||||
@@ -1362,7 +1373,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new request expectation for POST requests. For more info see `expect()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
|
||||
* receives data string and returns true if the data is as expected, or Object if request body
|
||||
* is in JSON format.
|
||||
@@ -1377,7 +1389,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new request expectation for PUT requests. For more info see `expect()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
|
||||
* receives data string and returns true if the data is as expected, or Object if request body
|
||||
* is in JSON format.
|
||||
@@ -1392,7 +1405,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new request expectation for PATCH requests. For more info see `expect()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
|
||||
* receives data string and returns true if the data is as expected, or Object if request body
|
||||
* is in JSON format.
|
||||
@@ -1407,7 +1421,8 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
* @description
|
||||
* Creates a new request expectation for JSONP requests. For more info see `expect()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @returns {requestHandler} Returns an object with `respond` method that control how a matched
|
||||
* request is handled.
|
||||
*/
|
||||
@@ -1531,6 +1546,7 @@ function MockHttpExpectation(method, url, data, headers) {
|
||||
this.matchUrl = function(u) {
|
||||
if (!url) return true;
|
||||
if (angular.isFunction(url.test)) return url.test(u);
|
||||
if (angular.isFunction(url)) return url(u);
|
||||
return url == u;
|
||||
};
|
||||
|
||||
@@ -1808,7 +1824,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* Creates a new backend definition.
|
||||
*
|
||||
* @param {string} method HTTP method.
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp)=} data HTTP request body.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
|
||||
* object and returns true if the headers match the current definition.
|
||||
@@ -1821,8 +1838,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* an array containing response status (number), response data (string) and response headers
|
||||
* (Object).
|
||||
* - passThrough – `{function()}` – Any request matching a backend definition with `passThrough`
|
||||
* handler, will be pass through to the real backend (an XHR request will be made to the
|
||||
* server.
|
||||
* handler will be passed through to the real backend (an XHR request will be made to the
|
||||
* server.)
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -1832,7 +1849,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* @description
|
||||
* Creates a new backend definition for GET requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
|
||||
* control how a matched request is handled.
|
||||
@@ -1845,7 +1863,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* @description
|
||||
* Creates a new backend definition for HEAD requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
|
||||
* control how a matched request is handled.
|
||||
@@ -1858,7 +1877,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* @description
|
||||
* Creates a new backend definition for DELETE requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
|
||||
* control how a matched request is handled.
|
||||
@@ -1871,7 +1891,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* @description
|
||||
* Creates a new backend definition for POST requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp)=} data HTTP request body.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
|
||||
@@ -1885,7 +1906,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* @description
|
||||
* Creates a new backend definition for PUT requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp)=} data HTTP request body.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
|
||||
@@ -1899,7 +1921,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* @description
|
||||
* Creates a new backend definition for PATCH requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @param {(string|RegExp)=} data HTTP request body.
|
||||
* @param {(Object|function(Object))=} headers HTTP headers.
|
||||
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
|
||||
@@ -1913,7 +1936,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
|
||||
* @description
|
||||
* Creates a new backend definition for JSONP requests. For more info see `when()`.
|
||||
*
|
||||
* @param {string|RegExp} url HTTP url.
|
||||
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
|
||||
* and returns true if the url match the current definition.
|
||||
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
|
||||
* control how a matched request is handled.
|
||||
*/
|
||||
|
||||
@@ -253,7 +253,7 @@ function shallowClearAndCopy(src, dst) {
|
||||
|
||||
```js
|
||||
var User = $resource('/user/:userId', {userId:'@id'});
|
||||
var user = User.get({userId:123}, function() {
|
||||
User.get({userId:123}, function(user) {
|
||||
user.abc = true;
|
||||
user.$save();
|
||||
});
|
||||
@@ -273,6 +273,16 @@ function shallowClearAndCopy(src, dst) {
|
||||
});
|
||||
});
|
||||
```
|
||||
*
|
||||
* You can also access the raw `$http` promise via the `$promise` property on the object returned
|
||||
*
|
||||
```
|
||||
var User = $resource('/user/:userId', {userId:'@id'});
|
||||
User.get({userId:123})
|
||||
.$promise.then(function(user) {
|
||||
$scope.user = user;
|
||||
});
|
||||
```
|
||||
|
||||
* # Creating a custom 'PUT' request
|
||||
* In this example we create a custom method on our resource to make a PUT request
|
||||
|
||||
@@ -119,38 +119,39 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
|
||||
</file>
|
||||
|
||||
<file name="script.js">
|
||||
angular.module('ngViewExample', ['ngRoute', 'ngAnimate'],
|
||||
function($routeProvider, $locationProvider) {
|
||||
$routeProvider.when('/Book/:bookId', {
|
||||
templateUrl: 'book.html',
|
||||
controller: BookCtrl,
|
||||
controllerAs: 'book'
|
||||
});
|
||||
$routeProvider.when('/Book/:bookId/ch/:chapterId', {
|
||||
templateUrl: 'chapter.html',
|
||||
controller: ChapterCtrl,
|
||||
controllerAs: 'chapter'
|
||||
});
|
||||
angular.module('ngViewExample', ['ngRoute', 'ngAnimate'])
|
||||
.config(['$routeProvider', '$locationProvider',
|
||||
function($routeProvider, $locationProvider) {
|
||||
$routeProvider
|
||||
.when('/Book/:bookId', {
|
||||
templateUrl: 'book.html',
|
||||
controller: 'BookCtrl',
|
||||
controllerAs: 'book'
|
||||
})
|
||||
.when('/Book/:bookId/ch/:chapterId', {
|
||||
templateUrl: 'chapter.html',
|
||||
controller: 'ChapterCtrl',
|
||||
controllerAs: 'chapter'
|
||||
});
|
||||
|
||||
// configure html5 to get links working on jsfiddle
|
||||
$locationProvider.html5Mode(true);
|
||||
});
|
||||
// configure html5 to get links working on jsfiddle
|
||||
$locationProvider.html5Mode(true);
|
||||
}])
|
||||
.controller('MainCtrl', ['$route', '$routeParams', '$location',
|
||||
function($route, $routeParams, $location) {
|
||||
this.$route = $route;
|
||||
this.$location = $location;
|
||||
this.$routeParams = $routeParams;
|
||||
}])
|
||||
.controller('BookCtrl', ['$routeParams', function($routeParams) {
|
||||
this.name = "BookCtrl";
|
||||
this.params = $routeParams;
|
||||
}])
|
||||
.controller('ChapterCtrl', ['$routeParams', function($routeParams) {
|
||||
this.name = "ChapterCtrl";
|
||||
this.params = $routeParams;
|
||||
}]);
|
||||
|
||||
function MainCtrl($route, $routeParams, $location) {
|
||||
this.$route = $route;
|
||||
this.$location = $location;
|
||||
this.$routeParams = $routeParams;
|
||||
}
|
||||
|
||||
function BookCtrl($routeParams) {
|
||||
this.name = "BookCtrl";
|
||||
this.params = $routeParams;
|
||||
}
|
||||
|
||||
function ChapterCtrl($routeParams) {
|
||||
this.name = "ChapterCtrl";
|
||||
this.params = $routeParams;
|
||||
}
|
||||
</file>
|
||||
|
||||
<file name="protractor.js" type="protractor">
|
||||
|
||||
+103
-99
@@ -82,7 +82,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.<Object>}` - 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
|
||||
@@ -90,7 +90,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.<Object>}` - route parameters extracted from the current
|
||||
* `$location.path()` by applying the current route
|
||||
*
|
||||
* - `resolve` - `{Object.<string, function>=}` - An optional map of dependencies which should
|
||||
@@ -247,7 +247,7 @@ function $RouteProvider(){
|
||||
* - `$scope` - The current route scope.
|
||||
* - `$template` - The current route template HTML.
|
||||
*
|
||||
* @property {Array.<Object>} routes Array of all configured routes.
|
||||
* @property {Object} routes Object with all route configuration Objects as its properties.
|
||||
*
|
||||
* @description
|
||||
* `$route` is used for deep-linking URLs to controllers and views (HTML partials).
|
||||
@@ -262,102 +262,106 @@ function $RouteProvider(){
|
||||
* {@link ngRoute.$routeParams `$routeParams`} service.
|
||||
*
|
||||
* @example
|
||||
This example shows how changing the URL hash causes the `$route` to match a route against the
|
||||
URL, and the `ngView` pulls in the partial.
|
||||
|
||||
Note that this example is using {@link ng.directive:script inlined templates}
|
||||
to get it working on jsfiddle as well.
|
||||
|
||||
<example name="$route-service" module="ngRouteExample" deps="angular-route.js" fixBase="true">
|
||||
<file name="index.html">
|
||||
<div ng-controller="MainCntl">
|
||||
Choose:
|
||||
<a href="Book/Moby">Moby</a> |
|
||||
<a href="Book/Moby/ch/1">Moby: Ch1</a> |
|
||||
<a href="Book/Gatsby">Gatsby</a> |
|
||||
<a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
|
||||
<a href="Book/Scarlet">Scarlet Letter</a><br/>
|
||||
|
||||
<div ng-view></div>
|
||||
<hr />
|
||||
|
||||
<pre>$location.path() = {{$location.path()}}</pre>
|
||||
<pre>$route.current.templateUrl = {{$route.current.templateUrl}}</pre>
|
||||
<pre>$route.current.params = {{$route.current.params}}</pre>
|
||||
<pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
|
||||
<pre>$routeParams = {{$routeParams}}</pre>
|
||||
</div>
|
||||
</file>
|
||||
|
||||
<file name="book.html">
|
||||
controller: {{name}}<br />
|
||||
Book Id: {{params.bookId}}<br />
|
||||
</file>
|
||||
|
||||
<file name="chapter.html">
|
||||
controller: {{name}}<br />
|
||||
Book Id: {{params.bookId}}<br />
|
||||
Chapter Id: {{params.chapterId}}
|
||||
</file>
|
||||
|
||||
<file name="script.js">
|
||||
angular.module('ngRouteExample', ['ngRoute'])
|
||||
|
||||
.config(function($routeProvider, $locationProvider) {
|
||||
$routeProvider.when('/Book/:bookId', {
|
||||
templateUrl: 'book.html',
|
||||
controller: BookCntl,
|
||||
resolve: {
|
||||
// I will cause a 1 second delay
|
||||
delay: function($q, $timeout) {
|
||||
var delay = $q.defer();
|
||||
$timeout(delay.resolve, 1000);
|
||||
return delay.promise;
|
||||
}
|
||||
}
|
||||
});
|
||||
$routeProvider.when('/Book/:bookId/ch/:chapterId', {
|
||||
templateUrl: 'chapter.html',
|
||||
controller: ChapterCntl
|
||||
});
|
||||
|
||||
// configure html5 to get links working on jsfiddle
|
||||
$locationProvider.html5Mode(true);
|
||||
});
|
||||
|
||||
function MainCntl($scope, $route, $routeParams, $location) {
|
||||
$scope.$route = $route;
|
||||
$scope.$location = $location;
|
||||
$scope.$routeParams = $routeParams;
|
||||
}
|
||||
|
||||
function BookCntl($scope, $routeParams) {
|
||||
$scope.name = "BookCntl";
|
||||
$scope.params = $routeParams;
|
||||
}
|
||||
|
||||
function ChapterCntl($scope, $routeParams) {
|
||||
$scope.name = "ChapterCntl";
|
||||
$scope.params = $routeParams;
|
||||
}
|
||||
</file>
|
||||
|
||||
<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('[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('[ng-view]')).getText();
|
||||
expect(content).toMatch(/controller\: BookCntl/);
|
||||
expect(content).toMatch(/Book Id\: Scarlet/);
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
* This example shows how changing the URL hash causes the `$route` to match a route against the
|
||||
* URL, and the `ngView` pulls in the partial.
|
||||
*
|
||||
* Note that this example is using {@link ng.directive:script inlined templates}
|
||||
* to get it working on jsfiddle as well.
|
||||
*
|
||||
* <example name="$route-service" module="ngRouteExample"
|
||||
* deps="angular-route.js" fixBase="true">
|
||||
* <file name="index.html">
|
||||
* <div ng-controller="MainController">
|
||||
* Choose:
|
||||
* <a href="Book/Moby">Moby</a> |
|
||||
* <a href="Book/Moby/ch/1">Moby: Ch1</a> |
|
||||
* <a href="Book/Gatsby">Gatsby</a> |
|
||||
* <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
|
||||
* <a href="Book/Scarlet">Scarlet Letter</a><br/>
|
||||
*
|
||||
* <div ng-view></div>
|
||||
*
|
||||
* <hr />
|
||||
*
|
||||
* <pre>$location.path() = {{$location.path()}}</pre>
|
||||
* <pre>$route.current.templateUrl = {{$route.current.templateUrl}}</pre>
|
||||
* <pre>$route.current.params = {{$route.current.params}}</pre>
|
||||
* <pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
|
||||
* <pre>$routeParams = {{$routeParams}}</pre>
|
||||
* </div>
|
||||
* </file>
|
||||
*
|
||||
* <file name="book.html">
|
||||
* controller: {{name}}<br />
|
||||
* Book Id: {{params.bookId}}<br />
|
||||
* </file>
|
||||
*
|
||||
* <file name="chapter.html">
|
||||
* controller: {{name}}<br />
|
||||
* Book Id: {{params.bookId}}<br />
|
||||
* Chapter Id: {{params.chapterId}}
|
||||
* </file>
|
||||
*
|
||||
* <file name="script.js">
|
||||
* angular.module('ngRouteExample', ['ngRoute'])
|
||||
*
|
||||
* .controller('MainController', function($scope, $route, $routeParams, $location) {
|
||||
* $scope.$route = $route;
|
||||
* $scope.$location = $location;
|
||||
* $scope.$routeParams = $routeParams;
|
||||
* })
|
||||
*
|
||||
* .controller('BookController', function($scope, $routeParams) {
|
||||
* $scope.name = "BookController";
|
||||
* $scope.params = $routeParams;
|
||||
* })
|
||||
*
|
||||
* .controller('ChapterController', function($scope, $routeParams) {
|
||||
* $scope.name = "ChapterController";
|
||||
* $scope.params = $routeParams;
|
||||
* })
|
||||
*
|
||||
* .config(function($routeProvider, $locationProvider) {
|
||||
* $routeProvider
|
||||
* .when('/Book/:bookId', {
|
||||
* templateUrl: 'book.html',
|
||||
* controller: 'BookController',
|
||||
* resolve: {
|
||||
* // I will cause a 1 second delay
|
||||
* delay: function($q, $timeout) {
|
||||
* var delay = $q.defer();
|
||||
* $timeout(delay.resolve, 1000);
|
||||
* return delay.promise;
|
||||
* }
|
||||
* }
|
||||
* })
|
||||
* .when('/Book/:bookId/ch/:chapterId', {
|
||||
* templateUrl: 'chapter.html',
|
||||
* controller: 'ChapterController'
|
||||
* });
|
||||
*
|
||||
* // configure html5 to get links working on jsfiddle
|
||||
* $locationProvider.html5Mode(true);
|
||||
* });
|
||||
*
|
||||
* </file>
|
||||
*
|
||||
* <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('[ng-view]')).getText();
|
||||
* expect(content).toMatch(/controller\: ChapterController/);
|
||||
* expect(content).toMatch(/Book Id\: Moby/);
|
||||
* expect(content).toMatch(/Chapter Id\: 1/);
|
||||
*
|
||||
* element(by.partialLinkText('Scarlet')).click();
|
||||
*
|
||||
* content = element(by.css('[ng-view]')).getText();
|
||||
* expect(content).toMatch(/controller\: BookController/);
|
||||
* expect(content).toMatch(/Book Id\: Scarlet/);
|
||||
* });
|
||||
* </file>
|
||||
* </example>
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -254,7 +254,7 @@ function htmlParser( html, handler ) {
|
||||
match = html.match( DOCTYPE_REGEXP );
|
||||
|
||||
if ( match ) {
|
||||
html = html.replace( match[0] , '');
|
||||
html = html.replace( match[0], '');
|
||||
chars = false;
|
||||
}
|
||||
// end tag
|
||||
|
||||
@@ -53,6 +53,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
||||
var ACTIVE_CLASS_NAME = 'ng-click-active';
|
||||
var lastPreventedTime;
|
||||
var touchCoordinates;
|
||||
var lastLabelClickCoordinates;
|
||||
|
||||
|
||||
// TAP EVENTS AND GHOST CLICKS
|
||||
@@ -124,10 +125,23 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
||||
var y = touches[0].clientY;
|
||||
// Work around desktop Webkit quirk where clicking a label will fire two clicks (on the label
|
||||
// and on the input element). Depending on the exact browser, this second click we don't want
|
||||
// to bust has either (0,0) or negative coordinates.
|
||||
// to bust has either (0,0), negative coordinates, or coordinates equal to triggering label
|
||||
// click event
|
||||
if (x < 1 && y < 1) {
|
||||
return; // offscreen
|
||||
}
|
||||
if (lastLabelClickCoordinates &&
|
||||
lastLabelClickCoordinates[0] === x && lastLabelClickCoordinates[1] === y) {
|
||||
return; // input click triggered by label click
|
||||
}
|
||||
// reset label click coordinates on first subsequent click
|
||||
if (lastLabelClickCoordinates) {
|
||||
lastLabelClickCoordinates = null;
|
||||
}
|
||||
// remember label click coordinates to prevent click busting of trigger click event on input
|
||||
if (event.target.tagName.toLowerCase() === 'label') {
|
||||
lastLabelClickCoordinates = [x, y];
|
||||
}
|
||||
|
||||
// Look for an allowable region containing this click.
|
||||
// If we find one, that means it was created by touchstart and not removed by
|
||||
|
||||
@@ -163,7 +163,7 @@ describe('injector', function() {
|
||||
function $f_n0 /*
|
||||
*/(
|
||||
$a, // x, <-- looks like an arg but it is a comment
|
||||
b_ , /* z, <-- looks like an arg but it is a
|
||||
b_, /* z, <-- looks like an arg but it is a
|
||||
multi-line comment
|
||||
function (a, b) {}
|
||||
*/
|
||||
|
||||
@@ -269,21 +269,27 @@ function provideLog($provide) {
|
||||
|
||||
log.toString = function() {
|
||||
return messages.join('; ');
|
||||
}
|
||||
};
|
||||
|
||||
log.toArray = function() {
|
||||
return messages;
|
||||
}
|
||||
};
|
||||
|
||||
log.reset = function() {
|
||||
messages = [];
|
||||
};
|
||||
|
||||
log.empty = function() {
|
||||
var currentMessages = messages;
|
||||
messages = [];
|
||||
return currentMessages;
|
||||
}
|
||||
|
||||
log.fn = function(msg) {
|
||||
return function() {
|
||||
log(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
log.$$log = true;
|
||||
|
||||
|
||||
@@ -168,6 +168,19 @@ describe('jqLite', function() {
|
||||
|
||||
dealoc(ul);
|
||||
});
|
||||
|
||||
it('should pass through DocumentFragment boundaries via host', function() {
|
||||
var host = jqLite('<div></div>'),
|
||||
frag = document.createDocumentFragment(),
|
||||
$frag = jqLite(frag);
|
||||
frag.host = host[0];
|
||||
host.data("foo", 123);
|
||||
host.append($frag);
|
||||
expect($frag.inheritedData("foo")).toBe(123);
|
||||
|
||||
dealoc(host);
|
||||
dealoc($frag);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
+62
-3
@@ -529,10 +529,18 @@ describe('$compile', function() {
|
||||
replace: true,
|
||||
template: '<th>TH</th>'
|
||||
}));
|
||||
directive('replaceWithThead', valueFn({
|
||||
replace: true,
|
||||
template: '<thead><tr><td>TD</td></tr></thead>'
|
||||
}));
|
||||
directive('replaceWithTbody', valueFn({
|
||||
replace: true,
|
||||
template: '<tbody><tr><td>TD</td></tr></tbody>'
|
||||
}));
|
||||
directive('replaceWithTfoot', valueFn({
|
||||
replace: true,
|
||||
template: '<tfoot><tr><td>TD</td></tr></tfoot>'
|
||||
}));
|
||||
}));
|
||||
|
||||
|
||||
@@ -718,12 +726,26 @@ describe('$compile', function() {
|
||||
expect(nodeName_(element)).toMatch(/th/i);
|
||||
}));
|
||||
|
||||
it('should support templates with root <thead> tags', inject(function($compile, $rootScope) {
|
||||
expect(function() {
|
||||
element = $compile('<div replace-with-thead></div>')($rootScope);
|
||||
}).not.toThrow();
|
||||
expect(nodeName_(element)).toMatch(/thead/i);
|
||||
}));
|
||||
|
||||
it('should support templates with root <tbody> tags', inject(function($compile, $rootScope) {
|
||||
expect(function() {
|
||||
element = $compile('<div replace-with-tbody></div>')($rootScope);
|
||||
}).not.toThrow();
|
||||
expect(nodeName_(element)).toMatch(/tbody/i);
|
||||
}));
|
||||
|
||||
it('should support templates with root <tfoot> tags', inject(function($compile, $rootScope) {
|
||||
expect(function() {
|
||||
element = $compile('<div replace-with-tfoot></div>')($rootScope);
|
||||
}).not.toThrow();
|
||||
expect(nodeName_(element)).toMatch(/tfoot/i);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
@@ -833,10 +855,18 @@ describe('$compile', function() {
|
||||
replace: true,
|
||||
templateUrl: 'th.html'
|
||||
}));
|
||||
directive('replaceWithThead', valueFn({
|
||||
replace: true,
|
||||
templateUrl: 'thead.html'
|
||||
}));
|
||||
directive('replaceWithTbody', valueFn({
|
||||
replace: true,
|
||||
templateUrl: 'tbody.html'
|
||||
}));
|
||||
directive('replaceWithTfoot', valueFn({
|
||||
replace: true,
|
||||
templateUrl: 'tfoot.html'
|
||||
}));
|
||||
}
|
||||
));
|
||||
|
||||
@@ -1500,6 +1530,15 @@ describe('$compile', function() {
|
||||
expect(nodeName_(element)).toMatch(/th/i);
|
||||
}));
|
||||
|
||||
it('should support templates with root <thead> tags', inject(function($compile, $rootScope, $templateCache) {
|
||||
$templateCache.put('thead.html', '<thead><tr><td>TD</td></tr></thead>');
|
||||
expect(function() {
|
||||
element = $compile('<div replace-with-thead></div>')($rootScope);
|
||||
}).not.toThrow();
|
||||
$rootScope.$digest();
|
||||
expect(nodeName_(element)).toMatch(/thead/i);
|
||||
}));
|
||||
|
||||
it('should support templates with root <tbody> tags', inject(function($compile, $rootScope, $templateCache) {
|
||||
$templateCache.put('tbody.html', '<tbody><tr><td>TD</td></tr></tbody>');
|
||||
expect(function() {
|
||||
@@ -1508,6 +1547,15 @@ describe('$compile', function() {
|
||||
$rootScope.$digest();
|
||||
expect(nodeName_(element)).toMatch(/tbody/i);
|
||||
}));
|
||||
|
||||
it('should support templates with root <tfoot> tags', inject(function($compile, $rootScope, $templateCache) {
|
||||
$templateCache.put('tfoot.html', '<tfoot><tr><td>TD</td></tr></tfoot>');
|
||||
expect(function() {
|
||||
element = $compile('<div replace-with-tfoot></div>')($rootScope);
|
||||
}).not.toThrow();
|
||||
$rootScope.$digest();
|
||||
expect(nodeName_(element)).toMatch(/tfoot/i);
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
@@ -1866,15 +1914,14 @@ describe('$compile', function() {
|
||||
|
||||
|
||||
describe('interpolation', function() {
|
||||
var observeSpy, directiveAttrs;
|
||||
var observeSpy, directiveAttrs, deregisterObserver;
|
||||
|
||||
beforeEach(module(function() {
|
||||
directive('observer', function() {
|
||||
return function(scope, elm, attr) {
|
||||
directiveAttrs = attr;
|
||||
observeSpy = jasmine.createSpy('$observe attr');
|
||||
|
||||
expect(attr.$observe('someAttr', observeSpy)).toBe(observeSpy);
|
||||
deregisterObserver = attr.$observe('someAttr', observeSpy);
|
||||
};
|
||||
});
|
||||
directive('replaceSomeAttr', valueFn({
|
||||
@@ -1972,6 +2019,18 @@ describe('$compile', function() {
|
||||
}));
|
||||
|
||||
|
||||
it('should return a deregistration function while observing an attribute', inject(function($rootScope, $compile) {
|
||||
$compile('<div some-attr="{{value}}" observer></div>')($rootScope);
|
||||
|
||||
$rootScope.$apply('value = "first-value"');
|
||||
expect(observeSpy).toHaveBeenCalledWith('first-value');
|
||||
|
||||
deregisterObserver();
|
||||
$rootScope.$apply('value = "new-value"');
|
||||
expect(observeSpy).not.toHaveBeenCalledWith('new-value');
|
||||
}));
|
||||
|
||||
|
||||
it('should set interpolated attrs to initial interpolation value', inject(function($rootScope, $compile) {
|
||||
$rootScope.whatever = 'test value';
|
||||
$compile('<div some-attr="{{whatever}}" observer></div>')($rootScope);
|
||||
|
||||
@@ -762,6 +762,718 @@ describe('input', function() {
|
||||
|
||||
|
||||
// INPUT TYPES
|
||||
describe('month', function (){
|
||||
it('should render blank if model is not a Date object', function() {
|
||||
compileInput('<input type="month" ng-model="january"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.january = '2013-01';
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
it('should set the view if the model is a valid Date object', function (){
|
||||
compileInput('<input type="month" ng-model="march"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.march = new Date(2013, 2, 1);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('2013-03');
|
||||
});
|
||||
|
||||
it('should set the model undefined if the input is an invalid month string', function () {
|
||||
compileInput('<input type="month" ng-model="value"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.value = new Date(2013, 0, 1);
|
||||
});
|
||||
|
||||
|
||||
expect(inputElm.val()).toBe('2013-01');
|
||||
|
||||
try {
|
||||
//set to text for browsers with datetime-local validation.
|
||||
inputElm[0].setAttribute('type', 'text');
|
||||
} catch(e) {
|
||||
//for IE8
|
||||
}
|
||||
|
||||
changeInputValueTo('stuff');
|
||||
expect(inputElm.val()).toBe('stuff');
|
||||
expect(scope.value).toBeUndefined();
|
||||
expect(inputElm).toBeInvalid();
|
||||
});
|
||||
|
||||
it('should render as blank if null', function() {
|
||||
compileInput('<input type="month" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toEqual('');
|
||||
});
|
||||
|
||||
it('should come up blank when no value specified', function() {
|
||||
compileInput('<input type="month" ng-model="test" />');
|
||||
|
||||
scope.$digest();
|
||||
expect(inputElm.val()).toBe('');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
|
||||
it('should parse empty string to null', function() {
|
||||
compileInput('<input type="month" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = new Date(2011, 0, 1);
|
||||
});
|
||||
|
||||
changeInputValueTo('');
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
|
||||
describe('min', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="month" ng-model="value" name="alias" min="2013-01" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('2012-12');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function (){
|
||||
changeInputValueTo('2013-07');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2013, 6, 1));
|
||||
expect(scope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function(){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="month" ng-model="value" name="alias" max="2013-01" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should validate', function (){
|
||||
changeInputValueTo('2012-03');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2012, 2, 1));
|
||||
expect(scope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('2013-05');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeUndefined();
|
||||
expect(scope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('week', function (){
|
||||
it('should set render blank if model is not a Date object', function() {
|
||||
compileInput('<input type="week" ng-model="secondWeek"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.secondWeek = '2013-W02';
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
it('should set the view if the model is a valid Date object', function (){
|
||||
compileInput('<input type="week" ng-model="secondWeek"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.secondWeek = new Date(2013, 0, 11);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('2013-W02');
|
||||
});
|
||||
|
||||
it('should set the model undefined if the input is an invalid week string', function () {
|
||||
compileInput('<input type="week" ng-model="value"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.value = new Date(2013, 0, 11);
|
||||
});
|
||||
|
||||
|
||||
expect(inputElm.val()).toBe('2013-W02');
|
||||
|
||||
try {
|
||||
//set to text for browsers with datetime-local validation.
|
||||
inputElm[0].setAttribute('type', 'text');
|
||||
} catch(e) {
|
||||
//for IE8
|
||||
}
|
||||
|
||||
changeInputValueTo('stuff');
|
||||
expect(inputElm.val()).toBe('stuff');
|
||||
expect(scope.value).toBeUndefined();
|
||||
expect(inputElm).toBeInvalid();
|
||||
});
|
||||
|
||||
it('should render as blank if null', function() {
|
||||
compileInput('<input type="week" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toEqual('');
|
||||
});
|
||||
|
||||
it('should come up blank when no value specified', function() {
|
||||
compileInput('<input type="week" ng-model="test" />');
|
||||
|
||||
scope.$digest();
|
||||
expect(inputElm.val()).toBe('');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
|
||||
it('should parse empty string to null', function() {
|
||||
compileInput('<input type="week" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = new Date(2011, 0, 1);
|
||||
});
|
||||
|
||||
changeInputValueTo('');
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
describe('min', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="week" ng-model="value" name="alias" min="2013-W01" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('2012-W12');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function (){
|
||||
changeInputValueTo('2013-W03');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2013, 0, 17));
|
||||
expect(scope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function(){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="week" ng-model="value" name="alias" max="2013-W01" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should validate', function (){
|
||||
changeInputValueTo('2012-W01');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2012, 0, 5));
|
||||
expect(scope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('2013-W03');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeUndefined();
|
||||
expect(scope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('datetime-local', function () {
|
||||
it('should render blank if model is not a Date object', function() {
|
||||
compileInput('<input type="datetime-local" ng-model="lunchtime"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.lunchtime = '2013-12-16T11:30';
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
it('should set the view if the model if a valid Date object.', function(){
|
||||
compileInput('<input type="datetime-local" ng-model="tenSecondsToNextYear"/>');
|
||||
|
||||
scope.$apply(function (){
|
||||
scope.tenSecondsToNextYear = new Date(2013, 11, 31, 23, 59);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('2013-12-31T23:59');
|
||||
});
|
||||
|
||||
it('should set the model undefined if the view is invalid', function (){
|
||||
compileInput('<input type="datetime-local" ng-model="breakMe"/>');
|
||||
|
||||
scope.$apply(function (){
|
||||
scope.breakMe = new Date(2009, 0, 6, 16, 25);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('2009-01-06T16:25');
|
||||
|
||||
try {
|
||||
//set to text for browsers with datetime-local validation.
|
||||
inputElm[0].setAttribute('type', 'text');
|
||||
} catch(e) {
|
||||
//for IE8
|
||||
}
|
||||
|
||||
changeInputValueTo('stuff');
|
||||
expect(inputElm.val()).toBe('stuff');
|
||||
expect(scope.breakMe).toBeUndefined();
|
||||
expect(inputElm).toBeInvalid();
|
||||
});
|
||||
|
||||
it('should render as blank if null', function() {
|
||||
compileInput('<input type="datetime-local" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toEqual('');
|
||||
});
|
||||
|
||||
it('should come up blank when no value specified', function() {
|
||||
compileInput('<input type="datetime-local" ng-model="test" />');
|
||||
|
||||
scope.$digest();
|
||||
expect(inputElm.val()).toBe('');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
|
||||
it('should parse empty string to null', function() {
|
||||
compileInput('<input type="datetime-local" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = new Date(2011, 0, 1);
|
||||
});
|
||||
|
||||
changeInputValueTo('');
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
describe('min', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="datetime-local" ng-model="value" name="alias" min="2000-01-01T12:30" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('1999-12-31T01:02');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function (){
|
||||
changeInputValueTo('2000-01-01T23:02');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2000, 0, 1, 23, 2));
|
||||
expect(scope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="datetime-local" ng-model="value" name="alias" max="2019-01-01T01:02" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('2019-12-31T01:02');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function() {
|
||||
changeInputValueTo('2000-01-01T01:02');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2000, 0, 1, 1, 2));
|
||||
expect(scope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should validate even if max value changes on-the-fly', function(done) {
|
||||
scope.max = '2013-01-01T01:02';
|
||||
compileInput('<input type="datetime-local" ng-model="value" name="alias" max="{{max}}" />');
|
||||
scope.$digest();
|
||||
|
||||
changeInputValueTo('2014-01-01T12:34');
|
||||
expect(inputElm).toBeInvalid();
|
||||
|
||||
scope.max = '2001-01-01T01:02';
|
||||
scope.$digest(function () {
|
||||
expect(inputElm).toBeValid();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should validate even if min value changes on-the-fly', function(done) {
|
||||
scope.min = '2013-01-01T01:02';
|
||||
compileInput('<input type="datetime-local" ng-model="value" name="alias" min="{{min}}" />');
|
||||
scope.$digest();
|
||||
|
||||
changeInputValueTo('2010-01-01T12:34');
|
||||
expect(inputElm).toBeInvalid();
|
||||
|
||||
scope.min = '2014-01-01T01:02';
|
||||
scope.$digest(function () {
|
||||
expect(inputElm).toBeValid();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('time', function () {
|
||||
it('should render blank if model is not a Date object', function() {
|
||||
compileInput('<input type="time" ng-model="lunchtime"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.lunchtime = '11:30';
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
it('should set the view if the model if a valid Date object.', function(){
|
||||
compileInput('<input type="time" ng-model="threeFortyOnePm"/>');
|
||||
|
||||
scope.$apply(function (){
|
||||
scope.threeFortyOnePm = new Date(0, 0, 1, 15, 41);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('15:41');
|
||||
});
|
||||
|
||||
it('should set the model undefined if the view is invalid', function (){
|
||||
compileInput('<input type="time" ng-model="breakMe"/>');
|
||||
|
||||
scope.$apply(function (){
|
||||
scope.breakMe = new Date(0, 0, 1, 16, 25);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('16:25');
|
||||
|
||||
try {
|
||||
//set to text for browsers with time validation.
|
||||
inputElm[0].setAttribute('type', 'text');
|
||||
} catch(e) {
|
||||
//for IE8
|
||||
}
|
||||
|
||||
changeInputValueTo('stuff');
|
||||
expect(inputElm.val()).toBe('stuff');
|
||||
expect(scope.breakMe).toBeUndefined();
|
||||
expect(inputElm).toBeInvalid();
|
||||
});
|
||||
|
||||
it('should render as blank if null', function() {
|
||||
compileInput('<input type="time" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toEqual('');
|
||||
});
|
||||
|
||||
it('should come up blank when no value specified', function() {
|
||||
compileInput('<input type="time" ng-model="test" />');
|
||||
|
||||
scope.$digest();
|
||||
expect(inputElm.val()).toBe('');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
|
||||
it('should parse empty string to null', function() {
|
||||
compileInput('<input type="time" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = new Date(2011, 0, 1);
|
||||
});
|
||||
|
||||
changeInputValueTo('');
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
describe('min', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="time" ng-model="value" name="alias" min="09:30" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('01:02');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function (){
|
||||
changeInputValueTo('23:02');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(0, 0, 1, 23, 2));
|
||||
expect(scope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="time" ng-model="value" name="alias" max="22:30" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('23:00');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function() {
|
||||
changeInputValueTo('05:30');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(0, 0, 1, 5, 30));
|
||||
expect(scope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should validate even if max value changes on-the-fly', function(done) {
|
||||
scope.max = '21:02';
|
||||
compileInput('<input type="time" ng-model="value" name="alias" max="{{max}}" />');
|
||||
scope.$digest();
|
||||
|
||||
changeInputValueTo('22:34');
|
||||
expect(inputElm).toBeInvalid();
|
||||
|
||||
scope.max = '12:34';
|
||||
scope.$digest(function () {
|
||||
expect(inputElm).toBeValid();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should validate even if min value changes on-the-fly', function(done) {
|
||||
scope.min = '08:45';
|
||||
compileInput('<input type="time" ng-model="value" name="alias" min="{{min}}" />');
|
||||
scope.$digest();
|
||||
|
||||
changeInputValueTo('06:15');
|
||||
expect(inputElm).toBeInvalid();
|
||||
|
||||
scope.min = '13:50';
|
||||
scope.$digest(function () {
|
||||
expect(inputElm).toBeValid();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('date', function () {
|
||||
it('should render blank if model is not a Date object.', function() {
|
||||
compileInput('<input type="date" ng-model="birthday"/>');
|
||||
|
||||
scope.$apply(function(){
|
||||
scope.birthday = '1977-10-22';
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
it('should set the view if the model if a valid Date object.', function(){
|
||||
compileInput('<input type="date" ng-model="christmas"/>');
|
||||
|
||||
scope.$apply(function (){
|
||||
scope.christmas = new Date(2013, 11, 25);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('2013-12-25');
|
||||
});
|
||||
|
||||
it('should set the model undefined if the view is invalid', function (){
|
||||
compileInput('<input type="date" ng-model="arrMatey"/>');
|
||||
|
||||
scope.$apply(function (){
|
||||
scope.arrMatey = new Date(2014, 8, 14);
|
||||
});
|
||||
|
||||
expect(inputElm.val()).toBe('2014-09-14');
|
||||
|
||||
try {
|
||||
//set to text for browsers with date validation.
|
||||
inputElm[0].setAttribute('type', 'text');
|
||||
} catch(e) {
|
||||
//for IE8
|
||||
}
|
||||
|
||||
changeInputValueTo('1-2-3');
|
||||
expect(inputElm.val()).toBe('1-2-3');
|
||||
expect(scope.arrMatey).toBeUndefined();
|
||||
expect(inputElm).toBeInvalid();
|
||||
});
|
||||
|
||||
it('should render as blank if null', function() {
|
||||
compileInput('<input type="date" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toEqual('');
|
||||
});
|
||||
|
||||
it('should come up blank when no value specified', function() {
|
||||
compileInput('<input type="date" ng-model="test" />');
|
||||
|
||||
scope.$digest();
|
||||
expect(inputElm.val()).toBe('');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = null;
|
||||
});
|
||||
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm.val()).toBe('');
|
||||
});
|
||||
|
||||
|
||||
it('should parse empty string to null', function() {
|
||||
compileInput('<input type="date" ng-model="test" />');
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.test = new Date(2011, 0, 1);
|
||||
});
|
||||
|
||||
changeInputValueTo('');
|
||||
expect(scope.test).toBeNull();
|
||||
expect(inputElm).toBeValid();
|
||||
});
|
||||
|
||||
describe('min', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="date" ng-model="value" name="alias" min="2000-01-01" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('1999-12-31');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.min).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function (){
|
||||
changeInputValueTo('2000-01-01');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2000, 0, 1));
|
||||
expect(scope.form.alias.$error.min).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('max', function (){
|
||||
beforeEach(function (){
|
||||
compileInput('<input type="date" ng-model="value" name="alias" max="2019-01-01" />');
|
||||
scope.$digest();
|
||||
});
|
||||
|
||||
it('should invalidate', function (){
|
||||
changeInputValueTo('2019-12-31');
|
||||
expect(inputElm).toBeInvalid();
|
||||
expect(scope.value).toBeFalsy();
|
||||
expect(scope.form.alias.$error.max).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should validate', function() {
|
||||
changeInputValueTo('2000-01-01');
|
||||
expect(inputElm).toBeValid();
|
||||
expect(+scope.value).toBe(+new Date(2000, 0, 1));
|
||||
expect(scope.form.alias.$error.max).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
it('should validate even if max value changes on-the-fly', function(done) {
|
||||
scope.max = '2013-01-01';
|
||||
compileInput('<input type="date" ng-model="value" name="alias" max="{{max}}" />');
|
||||
scope.$digest();
|
||||
|
||||
changeInputValueTo('2014-01-01');
|
||||
expect(inputElm).toBeInvalid();
|
||||
|
||||
scope.max = '2001-01-01';
|
||||
scope.$digest(function () {
|
||||
expect(inputElm).toBeValid();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should validate even if min value changes on-the-fly', function(done) {
|
||||
scope.min = '2013-01-01';
|
||||
compileInput('<input type="date" ng-model="value" name="alias" min="{{min}}" />');
|
||||
scope.$digest();
|
||||
|
||||
changeInputValueTo('2010-01-01');
|
||||
expect(inputElm).toBeInvalid();
|
||||
|
||||
scope.min = '2014-01-01';
|
||||
scope.$digest(function () {
|
||||
expect(inputElm).toBeValid();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('number', function() {
|
||||
|
||||
@@ -798,7 +1510,6 @@ describe('input', function() {
|
||||
expect(inputElm.val()).toEqual('');
|
||||
});
|
||||
|
||||
|
||||
it('should come up blank when no value specified', function() {
|
||||
compileInput('<input type="number" ng-model="age" />');
|
||||
|
||||
|
||||
@@ -733,6 +733,27 @@ describe('select', function() {
|
||||
expect(sortedHtml(options[2])).toEqual('<option value="1">3</option>');
|
||||
});
|
||||
|
||||
it('should not update selected property of an option element on digest with no change event',
|
||||
function() {
|
||||
createSingleSelect();
|
||||
|
||||
scope.$apply(function() {
|
||||
scope.values = [{name: 'A'}, {name: 'B'}, {name: 'C'}];
|
||||
scope.selected = scope.values[0];
|
||||
});
|
||||
|
||||
var options = element.find('option');
|
||||
var optionToSelect = options.eq(1);
|
||||
|
||||
expect(optionToSelect.text()).toBe('B');
|
||||
|
||||
optionToSelect.prop('selected', true);
|
||||
scope.$digest();
|
||||
|
||||
expect(optionToSelect.prop('selected')).toBe(true);
|
||||
expect(scope.selected).toBe(scope.values[0]);
|
||||
});
|
||||
|
||||
describe('binding', function() {
|
||||
|
||||
it('should bind to scope value', function() {
|
||||
|
||||
@@ -9,13 +9,65 @@ describe('style', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should not compile style element', inject(function($compile, $rootScope) {
|
||||
element = jqLite('<style type="text/css">should {{notBound}}</style>');
|
||||
it('should compile style element without binding', inject(function($compile, $rootScope) {
|
||||
element = jqLite('<style type="text/css">.header{font-size:1.5em; h3{font-size:1.5em}}</style>');
|
||||
$compile(element)($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
||||
// read innerHTML and trim to pass on IE8
|
||||
expect(trim(element[0].innerHTML)).toBe('should {{notBound}}');
|
||||
expect(trim(element[0].innerHTML)).toBe('.header{font-size:1.5em; h3{font-size:1.5em}}');
|
||||
}));
|
||||
|
||||
|
||||
it('should compile style element with one simple bind', inject(function($compile, $rootScope) {
|
||||
element = jqLite('<style type="text/css">.some-container{ width: {{elementWidth}}px; }</style>');
|
||||
$compile(element)($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
||||
// read innerHTML and trim to pass on IE8
|
||||
expect(trim(element[0].innerHTML)).toBe('.some-container{ width: px; }');
|
||||
|
||||
$rootScope.$apply(function() {
|
||||
$rootScope.elementWidth = 200;
|
||||
});
|
||||
|
||||
// read innerHTML and trim to pass on IE8
|
||||
expect(trim(element[0].innerHTML)).toBe('.some-container{ width: 200px; }');
|
||||
}));
|
||||
|
||||
|
||||
it('should compile style element with one bind', inject(function($compile, $rootScope) {
|
||||
element = jqLite('<style type="text/css">.header{ h3 { font-size: {{fontSize}}em }}</style>');
|
||||
$compile(element)($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
||||
// read innerHTML and trim to pass on IE8
|
||||
expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: em }}');
|
||||
|
||||
$rootScope.$apply(function() {
|
||||
$rootScope.fontSize = 1.5;
|
||||
});
|
||||
|
||||
// read innerHTML and trim to pass on IE8
|
||||
expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: 1.5em }}');
|
||||
}));
|
||||
|
||||
|
||||
it('should compile style element with two binds', inject(function($compile, $rootScope) {
|
||||
element = jqLite('<style type="text/css">.header{ h3 { font-size: {{fontSize}}{{unit}} }}</style>');
|
||||
$compile(element)($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
||||
// read innerHTML and trim to pass on IE8
|
||||
expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: }}');
|
||||
|
||||
$rootScope.$apply(function() {
|
||||
$rootScope.fontSize = 1.5;
|
||||
$rootScope.unit = 'em';
|
||||
});
|
||||
|
||||
// read innerHTML and trim to pass on IE8
|
||||
expect(trim(element[0].innerHTML)).toBe('.header{ h3 { font-size: 1.5em }}');
|
||||
}));
|
||||
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ describe('filters', function() {
|
||||
var noon = new angular.mock.TzDate(+5, '2010-09-03T17:05:08.012Z'); //12pm
|
||||
var midnight = new angular.mock.TzDate(+5, '2010-09-03T05:05:08.123Z'); //12am
|
||||
var earlyDate = new angular.mock.TzDate(+5, '0001-09-03T05:05:08.000Z');
|
||||
|
||||
var secondWeek = new angular.mock.TzDate(+5, '2013-01-11T12:00:00.000Z'); //Friday Jan 11, 2012
|
||||
var date;
|
||||
|
||||
beforeEach(inject(function($filter) {
|
||||
@@ -220,6 +220,12 @@ describe('filters', function() {
|
||||
});
|
||||
|
||||
it('should accept various format strings', function() {
|
||||
expect(date(secondWeek, 'yyyy-Ww')).
|
||||
toEqual('2013-W2');
|
||||
|
||||
expect(date(secondWeek, 'yyyy-Www')).
|
||||
toEqual('2013-W02');
|
||||
|
||||
expect(date(morning, "yy-MM-dd HH:mm:ss")).
|
||||
toEqual('10-09-03 07:05:08');
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user