Skip to content

Instantly share code, notes, and snippets.

@sax1johno
Created September 20, 2016 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sax1johno/379a4b705f2049ab47e0f881cec8f6d8 to your computer and use it in GitHub Desktop.
Save sax1johno/379a4b705f2049ab47e0f881cec8f6d8 to your computer and use it in GitHub Desktop.
Baseball Example created by sax1johno - https://repl.it/DdNO/3
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
</head>
<body>
</body>
</html>
angular.module("MyApp", ["AtBat"])
.controller("MyAppController", function($scope, AtBatState, GameState) {
$scope.balls = AtBatState.ball;
});
angular.module("AtBat", [])
.directive("atBat", function() {
return {
controller: function(AtBatState, GameState) {
},
template: "<div id='linefromfirsttosecond' ng-show='AtBatState.base >= 1'></div>",
link: function(scope, element, attributes) {
// This is where you draw stuff.
$(element).addChild();
scope.AtBatState = AtBatState;
}
};
})
.factory("AtBatService", function(AtBatState, GameState) {
return {
single: function() {
AtBatState.Ball = 0;
AtBatState.Strike = 0;
}
}
})
.value("AtBatState", {
"Base": 0,
"Ball": 0,
"Out": 0
}).value("GameState", {
"Home": {
},
"Away": {
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment