Skip to content

Instantly share code, notes, and snippets.

View mhevery's full-sized avatar

Miško Hevery mhevery

View GitHub Profile
<!doctype html>
<html xmlns:ng="http://angularjs.org" ng:app>
<script src="http://docs-next.angularjs.org/angular-0.10.6.min.js"></script>
<script>
function MainCntl($route, $routeParams, $location) {
this.$route = $route;
this.$location = $location;
this.$routeParams = $routeParams;
$route.when('/Book/:bookId', {template: 'examples/book.html', controller: BookCntl});
@mhevery
mhevery / gist:1590590
Created January 10, 2012 19:15
Demonstration of jsFiddle resource bug
<html>
<body>
<form class="jsfiddle" method="post" action="http://jsfiddle.net/api/post/library/pure/" target="_blank">
<textarea name="resources">http://code.angularjs.org/angular-0.10.5.min.js</textarea>
<textarea name="css"></textarea>
<input type="text" name="title" value="AngularJS Live Example">
<textarea name="html">&lt;div ng:app&gt;
&lt;div ng:controller="HelloCntl"&gt;
Your name: &lt;input type="text" ng:model="name" value="World"/&gt;
&lt;hr/&gt;
<html>
<head>
<script src="http://code.angularjs.org/angular-0.9.13.js" ng:autobind></script>
<script>
function MyCntrl($defer) {
var self = this;
this.list_of_items = ['this', 'that', 'the other'];
self.foo = {choice:''};
$defer(function(){
self.foo = {choice:'that'};
<html>
<head>
<script src="http://code.angularjs.org/angular-0.9.13.js" ng:autobind></script>
<script>
function MyCntrl() {
this.list_of_items = ['this', 'that', 'the other'];
this.foo = {choice:'that'};
}
MyCntrl.prototype = {
loadData: function(){
<!doctype html>
<html xmlns:ng="http://angularjs.org">
<script type="text/javascript" ng:autobind src="http://code.angularjs.org/0.9.10/angular-0.9.10.js"></script>
<script>
function MyApp(){
this.columns = ['name', 'description', 'amount'];
this.rows = [
{name:'name 0', description:'desc 0', amount:123},
{name:'name 1', description:'desc 1', amount:123},
{name:'name 2', description:'desc 2', amount:123},
<!doctype html>
<html xmlns:ng="http://angularjs.org">
<head>
<script type="text/javascript" src="http://code.angularjs.org/angular-0.9.8.js" ng:autobind></script>
<script type="text/javascript">
function Controller() {
var self = this;
this.sizes = [{w:320, h:200},{w:640, h:480},{w:800, h:600}];
this.rectangles = [
{name:"alfa", size:{w:640, h:480}},
@mhevery
mhevery / hello.cc
Created December 22, 2010 18:27
pHash for Node
#include <v8.h>
#include <pHash.h>
using namespace v8;
extern "C" void
init (Handle<Object> target)
{
HandleScope scope;
<!doctype html>
<html xmlns:ng="http://angularjs.org">
<script type="text/javascript" ng:autobind
src="http://code.angularjs.org/angular-0.9.2.min.js"></script>
<body>
<script>
angular.widget('my:time', function(compileElement /* i am a subset of jquery http://angularjs.org/Angular.element() */){
compileElement.css('display', 'block');
return function(linkElement /* i am a subset of jquery http://angularjs.org/Angular.element() */){
var div = angular.element('<div>Current time is: </div>');
@mhevery
mhevery / gist:662069
Created November 4, 2010 02:54
Hover in angular
<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript" ></script>
<script src="http://code.angularjs.org/angular-0.9.2.js" type="text/javascript" ng:autobind></script>
<script type="text/javascript">
function MyController(){
this.list_o_lists = [ ['e1', 'e2' ] , ['e3','e4','e5'] ];
this.$watch('$location.hashPath', this.userChange);
<!DOCTYPE HTML>
<html xmlns:ng="http://angularjs.org">
<head>
<script type="text/javascript"
src="http://code.angularjs.org/angular-0.9.0.js" ng:autobind></script>
</head>
<body>
<script>
function FetchCtrl() { }
FetchCtrl.prototype =