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
/** | |
* Fades an element in when the model changes. Restricted to attributes. | |
* | |
* Usage: | |
* | |
* <div di-fade-in="foo"/> | |
*/ | |
di.directive('diFadeIn', function () { | |
return { |
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
// <div fade-in="some_boolean">BOOM</div> | |
myApp.directive('fadeIn', function() { | |
return { | |
restrict: 'A', | |
link: function(scope, element, attribs) { | |
scope.$watch(attribs.fadeIn, function(value) { | |
if (value) { | |
element.fadeIn(); | |
} else { |
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
/** | |
* preventDefault: prevents the default action of the event from occurring. This is useful if | |
* you are using anchor tags and hash routing, wherein you do not want the anchor click to screw | |
* with your hashes. | |
* | |
* Usage: | |
* | |
* <a href="#" prevent-default="click">click me</a> | |
*/ | |
myModule.directive('preventDefault', function () { |
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
/*global angular*/ | |
/** | |
* Include this module if you want text boxes to update on blur instead of on keydown/input/change. | |
*/ | |
(function () { | |
'use strict'; | |
var blur = angular.module('decBlurModel', []); |
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
<html> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.3/angular.min.js"></script> | |
<script type="text/javascript"> | |
var myApp = angular.module('myApp',[]); | |
function MyCtrl($scope) { | |
$scope.name = 'Superhero'; | |
} |
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
$scope.submit = function submit() { | |
return $http({ | |
method: 'POST', | |
url: '/your/url', | |
headers: { | |
'Content-Type': 'multipart/form-data' | |
}, | |
data: { | |
file: $scope.file | |
}, |
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 myApp = angular.module('myApp', []); | |
myApp.controller('MyCtrl', ['$scope', function($scope) { | |
$scope.addTwo = function(n) { | |
return n + 2; | |
};}]); | |
myApp.service('MyService', function() { | |
this.addThree = function(n) { | |
return n + 3; |
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 myApp = angular.module('myApp', []); | |
var baseService = function () { | |
this._state = {}; | |
}; | |
baseService.prototype.getState = function () { | |
return this._state; | |
}; | |
baseService.prototype.setState = function (state) { | |
this._state = state; |
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 myApp = angular.module('myApp', []); | |
$(function () { | |
var body = $('body'), | |
injector = body.injector(), | |
giveMeJQueryPromise = function ($log, $timeout) { | |
var dfrd = $.Deferred(); | |
$log.log('deferring'); | |
$timeout(angular.noop, 2000).then(function () { | |
dfrd.resolve('deferred'); |
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
/** | |
* Enhanced Select2 Dropmenus | |
* | |
* @AJAX Mode - When in this mode, your value will be an object (or array of objects) of the data used by Select2 | |
* This change is so that you do not have to do an additional query yourself on top of Select2's own query | |
* @params [options] {object} The configuration options passed to $.fn.select2(). Refer to the documentation | |
*/ | |
angular.module('ui.directives').directive('uiSelect2', ['ui.config', '$timeout', '$parse', function (uiConfig, $timeout, $parse) { | |
var options = {}; | |
if (uiConfig.select2) { |
OlderNewer