Skip to content

Instantly share code, notes, and snippets.

Avatar

Vojta Jina vojtajina

  • San Francisco Bay Area
View GitHub Profile
View angular-bug-01.html
<!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 Nov 5, 2010
Angular - dynamic updating select
View gist:663471
<!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 Nov 16, 2010
Angular - service example
View gist:702566
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 Apr 7, 2011
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.
View angular-controller-repeater-issue.js
// controller
function MyCtrl() {
this.instMethod = function() {
return this.$id;
};
}
MyCtrl.prototype.protoMethod = function(index) {
return this.$id;
};
View angular-jqlite-issue-369.html
<!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 Jun 8, 2011
Angular Simple Widget with descend(true)
View angular-simple-widget.html
<!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 Jun 13, 2011
Angular - binding title example
View angular-bind-title.html
<!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 Jun 17, 2011
Angular Simple POST using $xhr
View angular-xhr-post.html
<!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 Jul 1, 2011
Angular - cancelling $route change
View angular-cancel-route-change.html
<!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 Jul 20, 2011
Angular - two different $locations on single page
View angular-two-locations.html
<!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>