This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------- MODULE ------------------- | |
/** | |
* Flattens array containing nested arrays into a one-level array. | |
* @param {Array} arr - array to flatten | |
* @returns {Array} flat array, always a new instance | |
*/ | |
function flattenArray(arr) { | |
if (!Array.isArray(arr)) throw new Error('First argument should be Array.'); | |
// result accumulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.directive('blurOnEnter', function(){ | |
return { | |
link: function (scope, element, attrs) { | |
element.bind("keypress", function (event) { | |
if(event.which === 13) { | |
element.blur(); | |
event.preventDefault(); | |
} | |
}); | |
} |