Skip to content

Instantly share code, notes, and snippets.

View B3nCr's full-sized avatar

Ben Crinion B3nCr

  • Sorted
  • United Kingdom
View GitHub Profile
@B3nCr
B3nCr / get-watchers.js
Created March 4, 2017 09:43 — forked from kentcdodds/get-watchers.js
Get Watchers of element and its children
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));
@B3nCr
B3nCr / gist:bbbe48a951e2cd366911
Last active August 29, 2015 14:13 — forked from anonymous/gist:97efc4f2f12ba51c5cf3
Angular directive which prevents form submit if it's not valid and sets Bootstrap classes
app.directive('validSubmit', ['$parse', function ($parse) {
return {
// we need a form controller to be on the same element as this directive
// in other words: this directive can only be used on a <form>
require: 'form',
// one time action per form
link: function (scope, element, iAttrs, form) {
form.$submitted = false;
// get a hold of the function that handles submission when form is valid
var fn = $parse(iAttrs.validSubmit);