Skip to content

Instantly share code, notes, and snippets.

View pablojim's full-sized avatar

Barry Fitzgerald pablojim

View GitHub Profile
angular.module('myApp.controllers', [])
.controller('MyCtrl', ['$scope', 'MyService', function ($scope, MyService) {
//Get promise and once resolved set it in the scope
MyService.fetchData('foo').then(function(result) {
$scope.result = result;
});
}]);
@pablojim
pablojim / gist:6172703
Created August 7, 2013 09:50
wrap method
/**
* Wrap a method with extended functionality, preserving the original function
* @param {Object} obj The context object that the method belongs to
* @param {String} method The name of the method to extend
* @param {Function} func A wrapper function callback. This function is called with the same arguments
* as the original function, except that the original function is unshifted and passed as the first
* argument.
*/
function wrap(obj, method, func) {
var proceed = obj[method];
@pablojim
pablojim / hchart.js
Created June 23, 2013 17:01
hcharts & sparklines
'use strict';
angular.module('mydashApp')
.directive('hchart', function () {
var seriesId = 0;
var ensureIds = function(series) {
series.forEach(function(s) {
if(!angular.isDefined(s.id)) {
s.id = "series-" + seriesId++;
}