Skip to content

Instantly share code, notes, and snippets.

View wholypantalones's full-sized avatar

Jason Dare wholypantalones

View GitHub Profile
@wholypantalones
wholypantalones / timedate.js
Created March 15, 2016 20:06
Angular UI Timepicker/Datepicker Format Time/Date Using Momentjs
//view <uib-timepicker ng-model="myModel.thing" ng-change="changed('whichModel',myModel.thing)" hour-step="timeConfig.hstep" minute-step="timeConfig.mstep" show-meridian="timeConfig.ismeridian"></uib-timepicker>
// controller
$scope.myModel ={};
$scope.timeConfig = {
hstep:1,
mstep:1,
ismeridian:true
};
$scope.changed = changed;
@wholypantalones
wholypantalones / findIndex.js
Created February 23, 2016 15:20
Angular find Index in array as service
//add as dependency
app.module('myApp',['findIndex']);
// inject into controller
app.module('myApp').controller('myController', function(IndexService) {
$scope.array[IndexService.getIndex($scope.array,'value to match in array',find this value)];
});
// service
angular.module('findIndex', []).factory('IndexService', function () {
return {
getIndex: function (arr,attr,val) {
@wholypantalones
wholypantalones / sort.css
Last active January 11, 2016 16:28
Angular Table Sorting
a.sort-link {color:#333}
a.sort-link:hover {cursor: pointer;text-decoration: none;color:#000}
@wholypantalones
wholypantalones / chosen-angular.js
Created January 11, 2016 13:41
Chosen Updated Directive
// fixes chosen updating for ng-options
angular.module('myApp', []).directive('chosen', function() {
var linker = function (scope, element, attrs) {
var list = attrs.chosen;
scope.$watch(list, function () {
element.trigger('chosen:updated');
});
scope.$watch(attrs.ngModel, function() {
@wholypantalones
wholypantalones / ES6Years.js
Last active March 28, 2017 12:14
Create Years Array
selectFullOfYears function() {
var now = new Date(),
year = now.getFullYear();
return Array.from(Array(num)).map((e, i) => year + i);
}
@wholypantalones
wholypantalones / chosen-angular-bootstrap-3.css
Last active January 12, 2016 18:59
Chosen / Angular Chosen Boostrap 3 CSS
/*
https://github.com/harvesthq/chosen
https://github.com/localytics/angular-chosen
*/
.chosen-container {width:100%!important}
.chosen-container-single .chosen-single {
background: #fff;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
@wholypantalones
wholypantalones / pageTitle.js
Created November 9, 2015 13:23
Angular Page Title With Routing
app.config(function ($routeProvider,$locationProvider) {
$routeProvider.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
title:'This Is The Page Title'
}).otherwise({
redirectTo: '/'
});
}).run(['$rootScope','$route','$location', function($rootScope,$route,$location) {
$rootScope.$on('$routeChangeSuccess', function() {
@wholypantalones
wholypantalones / daUtc.js
Created October 28, 2015 18:23
Angular Moment UTC Time
// requires moment, usage: {{timeStampString | utcTime}}
angular.module("ctrl", []).filter('utcTime', function() {
return function (utcTime) {
if (!utcTime) { return ''; }
var newTime = moment(utcTime).utcOffset(-5).format('h:mm A');
return newTime;
};
})
@wholypantalones
wholypantalones / unCamel.js
Created October 28, 2015 18:21
Angular unCamel
//usage <p>{{camelCaseStringOutput | uncamel}}
angular.module("ctrl", []).filter('uncamel', function() {
return function (uncamel) {
if (!uncamel) { return ''; }
var newValue = uncamel.replace(/([A-Z])/g, ' $1').replace(/^./, function(str){
return str.toUpperCase();
});
return newValue;
};
@wholypantalones
wholypantalones / doCookie.js
Created October 9, 2015 17:17
Angular watch cookie
$rootScope.$watch(function() {
return $cookies.get('COOKIE');
} , function(newValue) {
// do cookie things
});