Extending Javascript objects with a help of AngularJS extend method

Multiple ways of extending javascript objects

/**
 * One-way reference from subclass to superclass (instance)
 * Most of the time this is what you want. It should be done
 * before adding other methods to Subclass.
 */
ChildClass.prototype = new SuperClass();
 
/**
 * Two-way reference
 * Superclass will also get any Subclass methods added later.
 */
ChildClass.prototype = SuperClass.prototype;
 
/**
 * Cloning behavior
 * This does not setup a reference, so instanceof will not work.
 */
angular.extend(ChildClass.prototype, SuperClass.prototype);
 
/**
 * Enhancing a single instance
 * This could be used to implement the decorator pattern.
 */
angular.extend(subClassInstance, SuperClass.prototype);
Quote

Be that likable person

Become genuinely interested in other people.

Smile.

Remember that a person’s name is to that person the sweetest and most important sound in any language.

Be a good listener. Encourage others to talk about themselves.

Talk in terms of the other person’s interests.

Make the other person feel important and do it sincerely.

Smile, smile, smile :)

AngularJS directive multiple element

How to get AngularJS directive multiple element

You probably know there exists opening ng-repeat-start and finishing directive ng-repeat-end like:

<ul>
 <li ng-repeat-start="user in users">
   {{user.firstName}}
 </li>
 <li ng-repeat-end>
   {{user.firstName}}
 </li>
</ul>

You would think it is a specially made directive that works that way but actually it is not. It is part of any directive so you can use it inside your too. When you create new directory and inside you factory function you need to return an object with multiElement options set to true. This way it will behave same as ngRepeat directive over multiple non nested fields. Small excerpt from ngRepeat.js file denoting this:

var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
  ...
  return {
    restrict: 'A',
    <strong>multiElement: true,</strong>
    transclude: 'element',
    priority: 1000,
    terminal: true,
    ...
   }
}];

From native angularJS directive there are few more directives that support multi element spanning. They are ngIf, ngShow, ngHide and ngSwitch. So by adding multiElement to your custom directive you can make to transclude over angularjs directive multiple elements at the same time. This also comes handy because you can do nesting of multiple elements if they are contained inside another one.

How to record iPhone screen

To record iPhone screen has never been easier

Developing great new iOS application requires not just a usable application, but also a great video presentation of it. How it works, basic usability tricks to make users want to get your new application which you spent numerous hours to make it perfect.

If you are working alone on next big thing or inside a small agency or team and you probably have a limited budget to outsource your video production one of the hardest parts was shooting the actual content from iOS device, whether it is iPhone or iPad. Until now you could use some kind of recording of iOS simulator or using airplay method to sync the video. It worked but it was somehow clunky experience and you needed to buy extra software.

With the release of Mac OS Yosemite version everything has changed. Now you can record you iOS device screen directly without buying additional software whatsoever. All you need to have the computer upgraded to Yosemite version and an iPhone or iPad to latest iOS 8. iOS device needs to connect to your computer through lighting cable.

Continue reading