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
| //http://stackoverflow.com/questions/18790333/angular-js-render-value-without-data-binding | |
| app.directive('bindOnce', function() { | |
| return { | |
| scope: true, | |
| link: function( $scope, $element ) { | |
| setTimeout(function() { | |
| $scope.$destroy(); | |
| }, 0); | |
| } |
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
| (function() { | |
| var transitionEnd = 'transitionend webkitTransitionEnd oTransitionEnd'; | |
| function hideHandler() { | |
| $(this).hide(); | |
| } | |
| $.fn.transitionIn = function(cls) { | |
| var $this = this; | |
| $this.show(); | |
| $this.off(transitionEnd, hideHandler); | |
| var timer = window.setTimeout(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
| <div class="thumb"><div><img src="http://placeimg.com/300/200/animals"></div></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
| /** | |
| * Suggestディレクティブ | |
| */ | |
| angular.module('directives').directive('suggest',function($timeout) { | |
| return { | |
| restrict: 'AC', | |
| scope: { | |
| list: '=', | |
| model: '=ngModel', | |
| key: '@', |
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
| /** | |
| * URLエンコードしてモデルに値を入れ直すディレクティブ | |
| * <textarea ng-model="myModel" urldecode></textarea> | |
| */ | |
| angular.module('directives').directive('urldecode',function() { | |
| return { | |
| restrict: 'A', | |
| scope: { | |
| ngModel: '=' | |
| }, |
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
| /** | |
| * Shift+Enterでsubmitするディレクティブ | |
| */ | |
| angular.module("directives").directive("shiftSubmit", | |
| function() { | |
| return { | |
| restrict: 'AC', | |
| link : function($scope, $element, $attr){ | |
| var $form = angular.element(document[$attr.shiftSubmit]); | |
| $element.on("keydown", function(e) { |
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
| /** | |
| * 改行コードをbrに変換するフィルタ | |
| */ | |
| angular.module('filters').filter('lineBreak', function () { | |
| return function (input, exp) { | |
| return input.replace(/\n|\r/g, "<br>"); | |
| } | |
| }); |
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('controllers').controller('ExampleCtrl',function($scope,SocketService) { | |
| $scope.messages = []; | |
| SocketService.on('receive', function(message) { | |
| $scope.messages.unshift(message); | |
| }); | |
| $scope.send = function() { | |
| SocketService.emit('send',$scope.inputMessage); | |
| $scope.inputMessage = ''; | |
| }; | |
| }); |
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.js | |
| */ | |
| (function(angular) { | |
| var MODULES = [ | |
| 'ngSanitize', | |
| 'ngAnimate', | |
| 'ngRoute', | |
| 'ngCookies' | |
| ]; |