Last active
March 7, 2016 14:35
-
-
Save thosakwe/560693c9038e610854c0 to your computer and use it in GitHub Desktop.
Angular Snip for Upwork
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
angular.module('nba_app', []). | |
.controller('NBACtrl', NBAController) | |
.service('Hello', HelloService); |
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
function HelloService() { | |
this.hello = function() { | |
alert('Hi'); | |
} | |
} |
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
<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> |
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
//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