Skip to content

Instantly share code, notes, and snippets.

myApp.directive('capitalizeFirst', function($parse) {
return {
require: 'ngModel',
link: function(scope, element, attrs, modelCtrl) {
var capitalize = function(inputValue) {
if (inputValue === undefined) { inputValue = ''; }
var capitalized = inputValue.charAt(0).toUpperCase() +
inputValue.substring(1);
if(capitalized !== inputValue) {
modelCtrl.$setViewValue(capitalized);
angular.module('Scope.safeApply', [])
.run(['$rootScope', function ($rootScope) {
$rootScope.$safeApply = function () {
var fn, phase = this.$root.$$phase;
if (arguments.length == 1) {
fn = arguments[0];
} else {
@toboqus
toboqus / Binary Search
Created September 29, 2013 18:19
Binary searching through an array