MOVE wants to create an AngularJS app for their workout tracker Log. Here’s what it looks like. The tracker displays a list of exercises. Tapping the %20 or - changes the number of reps for that exercise.
-
-
Save Dyrits/5840af6b6f31c2bd2001c50bfa149fb3 to your computer and use it in GitHub Desktop.
MOVE Log
This file contains hidden or 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
const app = angular.module("MoveLogApp", []); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link | |
href="https://content.codecademy.com/projects/bootstrap.min.css" | |
rel="stylesheet" | |
/> | |
<link | |
href="https://fonts.googleapis.com/css?family=Oswald:400,700" | |
rel="stylesheet" | |
type="text/css" | |
/> | |
<link href="css/main.css" rel="stylesheet" /> | |
<script src="js/vendor/angular.min.js"></script> | |
</head> | |
<body ng-app="MoveLogApp"> | |
<div class="header"> | |
<div class="container">MOVE Log</div> | |
</div> | |
<div class="main" ng-controller="MainController"> | |
<div class="container" ng-repeat="exercise in exercises"> | |
<div class="row"> | |
<div class="exercise-icon col-xs-2"> | |
<img ng-src="{{ exercise.icon }}" /> | |
</div> | |
<div class="col-xs-6"> | |
<p class="exercise-name">{{ exercise.name }}</p> | |
</div> | |
<div class="col-xs-4 counters"> | |
<span class="decrease" ng-click="decrease(exercise)">-</span | |
><span class="count">{{ exercise.count }}</span | |
><span class="increase" ng-click="increase(exercise)">+</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="footer"> | |
<div class="container"></div> | |
</div> | |
<!-- Modules --> | |
<script src="js/app.js"></script> | |
<!-- Controllers --> | |
<script src="js/controllers/MainController.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
app.controller("MainController", [ | |
"$scope", | |
function ($scope) { | |
$scope.exercises = [ | |
{ | |
icon: "img/pushup.jpg", | |
name: "Pushups", | |
count: 20, | |
}, | |
{ | |
icon: "img/squat.jpg", | |
name: "Squats", | |
count: 15, | |
}, | |
{ | |
icon: "img/pullup.jpg", | |
name: "Pullups", | |
count: 10, | |
}, | |
{ | |
icon: "img/row.jpg", | |
name: "Rows", | |
count: 10, | |
}, | |
{ | |
icon: "img/lunge.jpg", | |
name: "Lunges", | |
count: 10, | |
}, | |
{ | |
icon: "img/stepup.jpg", | |
name: "Step Ups", | |
count: 10, | |
}, | |
{ | |
icon: "img/situp.jpg", | |
name: "Sit Ups", | |
count: 15, | |
}, | |
]; | |
$scope.increase = (exercise) => { exercise.count ++ }; | |
$scope.decrease = (exercise) => { exercise.count && exercise.count -- }; | |
}, | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment