Skip to content

Instantly share code, notes, and snippets.

Avatar

Emil van Galen evangalen

View GitHub Profile
@evangalen
evangalen / add-article.controller.js
Created Apr 23, 2016
Angular 1.0 - Simple Reddit
View add-article.controller.js
(function() { 'use strict';
angular
.module('app')
.controller('RedditAddArticleController', RedditAddArticleController)
/**
* @constructor
* @param $scope dependency injected child scope for this controller
View angularjs_directive_attribute_explanation.md

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://cdn.rawgit.com/babel/babel.github.io/master/scripts/babel.js"></script>
</head>
<body>
<script id="jsbin-javascript" type="text/babel">class A {};</script></body>
@evangalen
evangalen / app.js
Last active Dec 23, 2015
Plunk demonstrating AngularJS issue #1412 (= "input not showing invalid model values")
View app.js
angular.module('plunker', []);
@evangalen
evangalen / app.js
Last active Dec 23, 2015
Plunk demonstrating a fix for AngularJS issue #1412 (= "input not showing invalid model values") as well a fix 2 inconsistencies in the parsing of data entry.
View app.js
angular.module('plunker', ['jdFixInvalidValueFormatting', 'jdFixParsingInconsistencies']);
@evangalen
evangalen / app.js
Last active Dec 23, 2015
Plunk demonstrating a fix to render invalid values in a <input/> element; this effectively fixes AngularJS issue #1412 (= "input not showing invalid model values")
View app.js
angular.module('plunker', ['jdFixInvalidValueFormatting']);
@evangalen
evangalen / app.js
Last active Dec 23, 2015
Plunk using the custom "jdOnlyLetters" directive that does show invalid valid (as opposed to: ng-pattern="/^[a-zA-Z]*$/")
View app.js
angular.module('plunker', ['jdOnlyLetters']);
View jsfiddle-show-log-errors-to-firebug-lite.js
window.onerror = function(errorMsg, url, lineNumber) {
var text = document.documentElement.innerHTML;
var lines = text.match(/^.*((\r\n|\n|\r)|$)/gm);
var windowOnLoadLineNumber = null;
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (line.indexOf('window.onload') === 0) {
@evangalen
evangalen / $resource-with-default-update-action.js
Last active Dec 15, 2015
AngularJS module "ngResourceWithDefaultUpdateAction" which add a default "update" action to every $resource.
View $resource-with-default-update-action.js
angular.module('$resource-with-update-action', ['ngResource'], function($provide) {
$provide.decorator('$resource', function($delegate) {
var decoratedResourceFactory = function(url, paramDefaults, actions) {
var actionsWithDefaultUpdateAction =
angular.extend({}, { 'update': { method:'PUT' } }, actions);
return $delegate(url, paramDefaults, actionsWithDefaultUpdateAction);
};
@evangalen
evangalen / app.js
Created Mar 3, 2013
AngularJS Starter with Jasmine unit testing integrated (for usage in "http://plnkr.co/")
View app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});