This file contains hidden or 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
| var ngShowDirective = ['$animate', function($animate) { | |
| return function(scope, element, attr) { | |
| scope.$watch(attr.ngShow, function ngShowWatchAction(value){ | |
| $animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide'); | |
| }); | |
| }; | |
| }]; |
This file contains hidden or 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
| // The below config assumes all of your stylesheets are being requested from a `/stylesheets/` directory | |
| var express = require('express'), | |
| stylus = require('stylus'); | |
| var app = express.createServer(); | |
| app.configure(function () { | |
| // ... your middleware here | |
| app.use(stylus.middleware({ |
This file contains hidden or 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
| angular.config(function($provider) | |
| $provider.provider(function() { | |
| this._yolo = 'yolo' | |
| this.$get = function() { | |
| var yolo = this._yolo; | |
| var service = { | |
| currentYolo: function() { | |
| return yolo; | |
| } |
This file contains hidden or 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
| angular.module('YOUR_APP').config([ | |
| '$provide', function($provide) { | |
| return $provide.decorator('$rootScope', [ | |
| '$delegate', function($delegate) { | |
| $delegate.safeApply = function(fn) { | |
| var phase = $delegate.$$phase; | |
| if (phase === "$apply" || phase === "$digest") { | |
| if (fn && typeof fn === 'function') { | |
| fn(); | |
| } |
This file contains hidden or 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
| <ul ng-repeat="item in filteredItems = (items | filter:keyword)"> | |
| ... | |
| </ul> | |
| <div ng-hide="filteredItems.length">No items found</div> |
This file contains hidden or 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
| // Get device pixel ratio | |
| function getDPR() { | |
| var mediaQuery; | |
| // Fix fake window.devicePixelRatio on mobile Firefox | |
| var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; | |
| if (window.devicePixelRatio !== undefined && !is_firefox) { | |
| return window.devicePixelRatio; | |
| } else if (window.matchMedia) { | |
| mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5),\ | |
| (min--moz-device-pixel-ratio: 1.5),\ |
This file contains hidden or 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
| var app = angular.module('YOUR_APP') | |
| app.config(['$provide', function($provide) { | |
| $provide.decorator('$rootScope', ['$delegate', function($delegate) { | |
| Object.defineProperty($delegate.constructor.prototype, '$onRootScope', { | |
| value: function(name, listener){ | |
| var unsubscribe = $delegate.$on(name, listener); | |
| this.$on('$destroy', unsubscribe); | |
| }, |
This file contains hidden or 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
| angular.module('YOUR_APP', []) | |
| .config(['$provide', function($provide) { | |
| $provide.decorator('$rootScope', ['$delegate', function($delegate) { | |
| Object.defineProperty($delegate.constructor.prototype, '$safeApply', { | |
| value: function(scopeOrFunc, func, forceApply) { | |
| var $scope, fn, force = false; | |
| if (arguments.length == 1) { | |
| if (angular.isFunction(scopeOrFunc)) { |
This file contains hidden or 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
| app.config(function($provide) { | |
| $provide.decorator('$rootScope', function($delegate) { | |
| Object.defineProperty($delegate.constructor.prototype, '$debugMode', { | |
| value: true, | |
| writable: true, | |
| enumerable: false | |
| }); | |
| Object.defineProperty($delegate.constructor.prototype, '$toggleDebug', { |