AngularJS: Did you know…? From 1.0 to 1.3, part 2

Szymon Kosno
Nov 3, 2015 · 4 min read
Image for post
Image for post

This is a continuation of “AngularJS: Did you know…? From 1.0 to 1.3, part 1” focusing on functionalities made available around version 1.0–1.3. I will follow up in another post focusing on changes introduced somewhere between 1.3–1.4.

DISCLAIMER! This is not a change log or tutorial — it is just a list of features that might have been overlooked when working with Angular.

What features were introduced?

require: ‘ngModel’,
link: function(scope, elm, attrs, ctrl) {
if (ctrl && ctrl.$validators.email) {
// this will overwrite the default Angular email validator
ctrl. = function(modelValue, viewValue) {
return ctrl.$isEmpty(modelValue) ||
EMAIL_REGEXP.test(modelValue);
};
}
}

require: ‘ngModel’,
link: function(scope, elm, attrs, ctrl) {
var usernames = [‘Jim’, ‘John’, ‘Jill’, ‘Jackie’];
ctrl. = function(modelValue, viewValue) {

return promise;
};
}

var isolated = $scope.$new(true);
var other = $scope.$new(false, isolated);

.run([‘$anchorScroll’, function($anchorScroll) {
$anchorScroll.yOffset = 50; // always scroll by 50 extra pixels
}])

scope: { prop: '=*' }

$rootScope.log = ‘’;
$rootScope.$evalAsync(‘log = log + a’, {a: 1});
$rootScope.$digest();
expect($rootScope.log).toBe(‘1’);

  • values ‘f’, ‘0’, ‘false’, ‘no’, ’n’, ‘[]’ are no longer treated as falsy
  • only JavaScript falsy values are now treated as falsy by the expression parser; there are six of them: false, null, undefined, NaN, 0 and “”

scope.$eval(‘$eval.bind()’)

<isolated-directive some-attribute=”variableFromDirectiveScope”></isolated-directive>

//before you could pass and ‘/i’ would be used as flag
this.exp = ‘/abc/i’;
//now please use proper regular expression
this.exp = /abc/i;

<! — Markup: expression will not change once set 
<h1>{{ | uppercase}}<h1>
<h1>{{}}</h1>
<div style=”color: {{}}”>{{}}</div>
<! — within a directive
<qrcode code=””></qrcode>
<ul>
<li ng-repeat=”item in ”>{{item.name}}</li>
</ul>

filter.$stateful = true


See you next time — end of part 2

This post concludes list of “did you know” for versions 1.0–1.3. As always I urge you to read full AngularJS change log to always be up-to-date:

https://github.com/angular/angular.js/blob/master/CHANGELOG.md

If you have not seen it I also recommend reviewing part 1 of this post:

I will update this post with link to next one focused on changes done somewhere between 1.3 and 1.4.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store