This file contains 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
<!DOCTYPE HTML > | |
<html xmlns:ng="http://angularjs.org"> | |
<head> | |
<script type="text/javascript" src="http://angularjs.org/ng/js/angular-debug.js" ng:autobind></script> | |
<script type="text/javascript"> | |
function testController() { | |
// init the value | |
this.options = {1: 'one', 2: 'two'}; | |
this.change = function() { |
This file contains 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
describe('service-example', function() { | |
angular.service('notify', function(win) { | |
var msgs = []; | |
return function(msg) { | |
msgs.push(msg); | |
if (msgs.length == 3) { | |
win.alert(msgs.join("\n")); | |
msgs = []; | |
} |
This file contains 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
// controller | |
function MyCtrl() { | |
this.instMethod = function() { | |
return this.$id; | |
}; | |
} | |
MyCtrl.prototype.protoMethod = function(index) { | |
return this.$id; | |
}; |
This file contains 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
<!doctype html> | |
<html xmlns:ng="http://angularjs.org"> | |
<head> | |
<script src="http://code.angularjs.org/0.9.14/angular-0.9.14.js"></script> | |
</head> | |
<body> | |
<script> | |
// create element by jqLite | |
var s1 = angular.element('<script>') | |
.attr({type: 'text/javascript', src: 'http://code.angularjs.org/0.9.15/angular-0.9.15.js?param1'}); |
This file contains 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
<!DOCTYPE HTML> | |
<html xmlns:ng="http://angularjs.org"> | |
<script type="text/javascript" src="http://code.angularjs.org/0.9.16/angular-0.9.16.min.js" ng:autobind></script> | |
<script type="text/javascript"> | |
angular.widget('my:test', function(element) { | |
// compile children elements ? | |
this.descend(true); | |
element.append('<button type="button" ng:click="testIt()">TEST</button>'); | |
}); | |
This file contains 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
<!doctype html> | |
<html xmlns:ng="http://angularjs.org"> | |
<script src="http://code.angularjs.org/0.9.17/angular-0.9.17.js" ng:autobind></script> | |
<body> | |
<script> | |
function BookCntl() { | |
this.name = "BookCntl"; | |
} | |
This file contains 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
<!DOCTYPE html> | |
<html xmlns:ng="http://angularjs.org"> | |
<head> | |
<title>NG playground</title> | |
<script src="/build/angular.js"></script> | |
<style> | |
div {margin: 5px; padding: 0 10px 10px 10px; border: 1px solid black;} | |
input {width: 400px;} | |
</style> | |
</head> |
This file contains 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
// pseudocode | |
angular.service('$eventBus', function() { | |
var listeners = {}; | |
var mainBus = function(scope) { | |
return new ChildBus(mainBus, scope); | |
}; | |
mainBus.emit = function(type) { | |
var args = Array.prototype.slice.call(arguments, 1); |
This file contains 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
#!/bin/sh | |
# | |
# Simple script for rewriting history :-D | |
# Might be helpful when using "rebasing" strategy to keep your history nice and flat... | |
# | |
# Instalation | |
# >> sudo bash -c "curl https://raw.github.com/gist/1341268/git-edit.sh > /usr/local/bin/git-edit" | |
# >> sudo chmod a+x /usr/local/bin/git-edit | |
# | |
# Usage |
This file contains 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
// GOOGLE3 usage - bigger projects | |
var MyController = function($scope, $location) { | |
// controller's private state | |
this.$location = $location; | |
this.some = 12; | |
this.$scope = $scope; | |
// methods accessible from template | |
// these methods (defined in constructor) should contain only few logic, |