Skip to content

Instantly share code, notes, and snippets.

View vojtajina's full-sized avatar

Vojta Jina vojtajina

  • San Francisco Bay Area
View GitHub Profile
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:ng="http://angularjs.org">
<head>
<script type="text/javascript" src="../angular.js/src/angular-bootstrap.js" ng:autobind></script>
</head>
<body>
<script type="text/javascript">
angular.markup('---', function(text, textNode, parentElement) {
var compiler = this;
@vojtajina
vojtajina / gist:663471
Created November 5, 2010 00:47
Angular - dynamic updating select
<!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() {
@vojtajina
vojtajina / gist:702566
Created November 16, 2010 21:40
Angular - service example
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 = [];
}
@vojtajina
vojtajina / angular-controller-repeater-issue.js
Created April 7, 2011 14:51
Angular issue: There is a different this (inside the method - different scope object), if controller method is defined in instance than if defined in prototype. This applies only when related element has been created by ng:repeater.
// controller
function MyCtrl() {
this.instMethod = function() {
return this.$id;
};
}
MyCtrl.prototype.protoMethod = function(index) {
return this.$id;
};
@vojtajina
vojtajina / angular-jqlite-issue-369.html
Created June 6, 2011 13:20
Angular jgLite issue #369
<!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'});
@vojtajina
vojtajina / angular-simple-widget.html
Created June 8, 2011 15:50
Angular Simple Widget with descend(true)
<!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>');
});
@vojtajina
vojtajina / angular-bind-title.html
Created June 13, 2011 12:56
Angular - binding title example
<!DOCTYPE HTML>
<html xmlns:ng="http://angularjs.org" ng:controller="Main">
<head>
<title ng:bind-template="Prefix: {{pageTitle}}"></title>
<script type="text/javascript" src="build/angular.js" ng:autobind></script>
<script type="text/javascript">
function Main(){}
function Child(){}
</script>
@vojtajina
vojtajina / angular-xhr-post.html
Created June 17, 2011 16:45
Angular Simple POST using $xhr
<!DOCTYPE HTML>
<html xmlns:ng="http://code.angularjs.org/0.9.16/angular-0.9.16.min.js" ng:controller="Main">
<head>
<title>Simple Example of Angular's $xhr</title>
<script type="text/javascript" src="build/angular.js" ng:autobind></script>
<script type="text/javascript">
function Main($xhr){
var selft = this;
this.doRequest = function() {
$xhr('POST', 'url.php', 'data-content=233', function(code, response) {
@vojtajina
vojtajina / angular-cancel-route-change.html
Created July 1, 2011 15:07
Angular - cancelling $route change
<!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";
}
@vojtajina
vojtajina / angular-two-locations.html
Created July 20, 2011 20:31
Angular - two different $locations on single page
<!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>