Skip to content

Instantly share code, notes, and snippets.

Avatar

Pete Bacon Darwin petebacondarwin

View GitHub Profile
View app.js
var oldModelValue, newModelValue, counter;
function watchModelFn(scope) {
newModelValue = ngModelGet(scope);
if (
!updatingFromTheView &&
!(newModelValue === undefined && $valid === false) &&
!modelEquals(newModelValue, oldModelValue)
) {
View docs.js
[ 'angular2/annotations : module',
'angular2/annotations/ComponentAnnotation.changeDetection : member',
'angular2/annotations/ComponentAnnotation.viewInjector : member',
'angular2/annotations/ComponentAnnotation.constructor : member',
'angular2/annotations/ComponentAnnotation : class',
'angular2/annotations/DirectiveAnnotation.selector : member',
'angular2/annotations/DirectiveAnnotation.properties : member',
'angular2/annotations/DirectiveAnnotation.events : member',
'angular2/annotations/DirectiveAnnotation.host : member',
'angular2/annotations/DirectiveAnnotation.lifecycle : member',
@petebacondarwin
petebacondarwin / angular2.d.ts
Created Jul 14, 2015
Latest Angular 2 type definition
View angular2.d.ts
// Type definitions for Angular v2.0.0-local_sha.7dc1dff
// Project: http://angular.io/
// Definitions by: angular team <https://github.com/angular/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// ***********************************************************
// This file is generated by the Angular build process.
// Please do not create manual edits or send pull requests
// modifying this file.
// ***********************************************************
View ng-route-web-components-crash.html
<!DOCTYPE html>
<html>
<body>
<template id='my-component-template'>
<style>
@import url('whatever...');
</style>
</template>
View gist:020c78b256dc6d04b5a0
index.html
<div ng-include="templateUrl"></div>
template1.html
<h1>Hello</h1>
View app.js
'use strict';
var app = angular.module('myApp', [
'ngRoute'
]);
app.run(function ($rootScope, $location) {
var myArray = [];
for (var i = 0; i < 500; i++) {
@petebacondarwin
petebacondarwin / app.js
Created Dec 15, 2014
Suggested extendable $http configuration...
View app.js
angular.module('resources', [])
// So we create a new service for each configuration of $http that we want
.factory('myServerAPI', function($http) {
function customRequestTransform(value) { ... }
function customResponseTransform(value) { ... }
// Provide a configuration object that corresponds to our specific $http needs
View angular-route.js
/**
* @license AngularJS v1.3.2-local+sha.91834bc
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {'use strict';
/**
* @ngdoc module
* @name ngRoute
@petebacondarwin
petebacondarwin / index.html
Created Sep 3, 2014
AngularJS $location HTML5 mode "local" URLs
View index.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
var e = document.createElement("base");
e.setAttribute("href",location.pathname);
console.log(location.pathname);
document.head.appendChild(e);
</script>
View gist:11264789
<form ng-message-include="form-messages">
<input class="form-control" type="text" name="first_name" id="input_first_name" ng-model="data.first_name" required />
<div class="error-messages" ng-if="interacted(my_form.first_name)" ng-message="my_form.first_name.$error">
<div ng-message-on="required">You did not enter your first name</div>
</div>
<input class="form-control" type="text" name="last_name" id="input_last_name" ng-model="data.last_name" required />
<div class="error-messages" ng-if="interacted(my_form.last_name)" ng-message="my_form.last_name.$error">
<div ng-message-on="required">You did not enter your last name</div>
</div>