angular-scenario
Advanced tools
Changelog
1.4.5 permanent-internship (2015-08-28)
$animate.enabled(false)
should disable animations on $animateCss as well
(c3d5e33e,
#12696, #12685)The ngPattern
and pattern
directives will validate the regex
against the viewValue
of ngModel
, i.e. the value of the model
before the $parsers are applied. Previously, the modelValue
(the result of the $parsers) was validated.
This fixes issues where input[date]
and input[number]
cannot
be validated because the viewValue string is parsed into
Date
and Number
respectively (starting with AngularJS 1.3).
It also brings the directives in line with HTML5 constraint
validation, which validates against the input value.
This change is unlikely to cause applications to fail, because even in AngularJS 1.2, the value that was validated by pattern could have been manipulated by the $parsers, as all validation was done inside this pipeline.
If you rely on the pattern being validated against the modelValue, you must create your own validator directive that overwrites the built-in pattern validator:
.directive('patternModelOverwrite', function patternModelOverwriteDirective() {
return {
restrict: 'A',
require: '?ngModel',
priority: 1,
compile: function() {
var regexp, patternExp;
return {
pre: function(scope, elm, attr, ctrl) {
if (!ctrl) return;
attr.$observe('pattern', function(regex) {
/**
* The built-in directive will call our overwritten validator
* (see below). We just need to update the regex.
* The preLink fn guarantees our observer is called first.
*/
if (isString(regex) && regex.length > 0) {
regex = new RegExp('^' + regex + '$');
}
if (regex && !regex.test) {
//The built-in validator will throw at this point
return;
}
regexp = regex || undefined;
});
},
post: function(scope, elm, attr, ctrl) {
if (!ctrl) return;
regexp, patternExp = attr.ngPattern || attr.pattern;
//The postLink fn guarantees we overwrite the built-in pattern validator
ctrl.$validators.pattern = function(value) {
return ctrl.$isEmpty(value) ||
isUndefined(regexp) ||
regexp.test(value);
};
}
};
}
};
});
<a name="1.3.18"></a>
Changelog
1.4.4 pylon-requirement (2015-08-13)
skipBlocking
avoids the pre-emptive transition-delay styling
(11695ca6)=
signs in values in parseKeyValue
(f13852c1,
#12351)$animateCss
(39b634e5,
#12509)The previous behavior involved ngAnimate having to wait for one
requestAnimationFrame before CSS classes were added/removed. The CSS classes
are now applied directly after the first digest that is triggered after
$animate.addClass
, $animate.removeClass
or $animate.setClass
is
called. If any of your code relies on waiting for one frame before
checking for CSS classes on the element then please change this
behavior. If a parent class-based animation, however, is run through a
JavaScript animation which triggers an animation for beforeAddClass
and/or beforeRemoveClass
then the CSS classes will not be applied
in time for the children (and the parent class-based animation will not
be cancelled by any child animations).
$timeout.flush()
to resolve a call to $q.when
with a value.The previous behavior involved creating an extra promise that needed to be resolved. This is no longer needed when
$q.when
is called with a value. In the case that the test is not aware if $q.when
is called with a value or
another promise, it is possible to replace $timeout.flush();
with $timeout.flush(0);
.
describe('$q.when', function() {
it('should not need a call to $timeout.flush() to resolve already resolved promises',
inject(function($q, $timeout) {
$q.when('foo');
// In AngularJS 1.4.3 a call to `$timeout.flush();` was needed
$timeout.verifyNoPendingTasks();
}));
it('should accept $timeout.flush(0) when not sure if $q.when was called with a value or a promise',
inject(function($q, $timeout) {
$q.when('foo');
$timeout.flush(0);
$timeout.verifyNoPendingTasks();
}));
it('should need a call to $timeout.flush() to resolve $q.when when called with a promise',
inject(function($q, $timeout) {
$q.when($q.when('foo'));
$timeout.flush();
$timeout.verifyNoPendingTasks();
}));
});
form: Due to 94533e57,
the name
attribute of form
elements can now only contain characters that can be evaluated as part
of an Angular expression. This is because Angular uses the value of name
as an assignable expression
to set the form on the $scope
. For example, name="myForm"
assigns the form to $scope.myForm
and
name="myObj.myForm"
assigns it to $scope.myObj.myForm
.
Previously, it was possible to also use names such name="my:name"
, because Angular used a special setter
function for the form name. Now the general, more robust $parse
setter is used.
The easiest way to migrate your code is therefore to remove all special characters from the name
attribute.
If you need to keep the special characters, you can use the following directive, which will replace
the name
with a value that can be evaluated as an expression in the compile function, and then
re-set the original name in the postLink function. This ensures that (1), the form is published on
the scope, and (2), the form has the original name, which might be important if you are doing server-side
form submission.
angular.module('myApp').directive('form', function() {
return {
restrict: 'E',
priority: 1000,
compile: function(element, attrs) {
var unsupportedCharacter = ':'; // change accordingly
var originalName = attrs.name;
if (attrs.name && attrs.name.indexOf(unsupportedCharacter) > 0) {
attrs.$set('name', 'this["' + originalName + '"]');
}
return postLinkFunction(scope, element) {
// Don't trigger $observers
element.setAttribute('name', originalName);
}
}
};
});
<a name="1.4.3"></a>
Changelog
1.4.3 foam-acceleration (2015-07-15)
<a name="1.4.2"></a>
Changelog
1.4.2 nebular-readjustment (2015-07-06)
src
attribute of ngInclude no longer accepts an
expression that returns the result of $sce.trustAsResourceUrl
. This will now cause an infinite digest:Before:
<div ng-include="findTemplate('https://example.com/myTemplate.html')"></div>
$scope.findTemplate = function(templateName) {
return $sce.trustAsResourceUrl(templateName);
};
To migrate, either cache the result of trustAsResourceUrl()
, or put the template url in the resource
whitelist in the config()
function:
After:
var templateCache = {};
$scope.findTemplate = function(templateName) {
if (!templateCache[templateName]) {
templateCache[templateName] = $sce.trustAsResourceUrl(templateName);
}
return templateCache[templateName];
};
// Alternatively, use `$sceDelegateProvider.resourceUrlWhitelist()`:
angular.module('myApp', []).config(function($sceDelegateProvider) {
$sceDelegateProvider.resourceUrlWhitelist(['self', 'https://example.com/**'])
});
<a name="1.3.17"></a>
Changelog
1.4.1 hyperionic-illumination (2015-06-16)
$locationChangeSuccess
(91b60226,
#11439, #11675, #11935, #12083)undefined
(71fc3f4f,
#12099)
(d19504a1,
#11959)tabindex
attribute
(799353c7,
#8371, #5853)numberInputType
directive
(ebd0fbba,
#12121, #12122)multidir
error
(351fe4b7,
#11775)<a name="1.3.16"></a>
Changelog
1.3.16 cookie-oatmealification (2015-06-05)
success
and error
methods do not receive a function
(731e1f65,
#11330, #11333)null
/undefined
(9dd0fe35,
#11573, #11617)<a name="1.4.0"></a>
Changelog
1.4.0 jaracimrman-existence (2015-05-26)
<a name="1.4.0-rc.2"></a>
Changelog
1.4.0-rc.2 rocket-zambonimation (2015-05-12)
ng-anchor
instead of a suffixed -anchor
CSS class when triggering anchor animations
(df24410c)ng-animate-anchor
to ng-anchor
(e6d053de)ng-animate
class with classNameFilter
(1002b80a,
#11431, #11807)// before
var animator = $animateCss(element, { ... });
if (!animator) {
continueApp();
return;
}
var runner = animator.start();
runner.done(continueApp);
runner.then(continueApp);
// now
var animator = $animateCss(element, { ... });
var runner = animator.start();
runner.done(continueApp);
runner.then(continueApp);
Instead just use the ng-anchor
CSS class like so:
<div class="container-animation" ng-if="on">
<div ng-animate-ref="1" class="my-anchor-element"></div>
</div>
<div class="container-animation" ng-if="!on">
<div ng-animate-ref="1" class="my-anchor-element"></div>
</div>
before:
/* before (notice the container-animation CSS class) */
.container-animation-anchor {
transition:0.5s linear all;
}
now:
/* now (just use `ng-anchor` on a class that both the
elements that contain `ng-animate-ref` share) */
.my-anchor-element.ng-anchor {
transition:0.5s linear all;
}
due to e6d053de,
if your CSS code made use of the ng-animate-anchor
CSS class for referencing the anchored animation element then your
code must now use ng-anchor
instead.
due to 1002b80a,
partially or fully using a regex value containing
ng-animate
as a token is not allowed anymore. Doing so will trigger a
minErr exception to be thrown.
So don't do this:
// only animate elements that contain the `ng-animate` CSS class
$animateProvider.classNameFilter(/ng-animate/);
// or partially contain it
$animateProvider.classNameFilter(/some-class ng-animate another-class/);
but this is OK:
$animateProvider.classNameFilter(/ng-animate-special/);
Although it is unlikely that anyone is using it in this way, this change does change the
behavior of ngOptions
in the following case:
ngOptions
syntax
(item.label for item in items
) and that object contains non-numeric property keys.In this case these properties with non-numeric keys will be ignored.
** Here array-like is defined by the result of a call to this internal function: https://github.com/angular/angular.js/blob/v1.4.0-rc.1/src/Angular.js#L198-L211 **
To get the desired behavior you need to iterate using the object form of the ngOptions
syntax
(value.label
for (key, value) in items)`).
<a name="v1.4.0-rc.1"></a>