Skip to content

Instantly share code, notes, and snippets.

@thosakwe
Last active March 7, 2016 14:35
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 thosakwe/560693c9038e610854c0 to your computer and use it in GitHub Desktop.
Save thosakwe/560693c9038e610854c0 to your computer and use it in GitHub Desktop.
Angular Snip for Upwork
angular.module('nba_app', []).
.controller('NBACtrl', NBAController)
.service('Hello', HelloService);
function HelloService() {
this.hello = function() {
alert('Hi');
}
}
<div ng-controller="NBACtrl as NBA">
<h1>Teams</h1>
<ul>
<li ng-repeat="team in NBA.teams">{{team.name}} ({{teams.wins}} - {{team.losses}})</li>
</ul>
</div>
//I would prefer ES6, but
function NBAController(Hello) {
this.teams = [{name: 'Warriors', wins: 55, losses: 6, conference: 'west'}, {name: 'Heat', wins: 37, losses: 26. conference: 'east'}];
this.predictWinner = function(team1, team2) {
var winner = team1.wins > team2.wins ? team1 : team2;
alert('The ' + winner.name + ' would win this matchup.');
Hello.hello();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment