Skip to content

Angular Homework #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(function(){

var app = angular.module('movieApp', []);

app.controller('MovieCtrl', ['$scope', function($scope){
$scope.moviesToWatch =[
{
name: "John Wick"
},
{
name: "The Green Mile"
},
{
name: "The Intouchables"
},
{
name: "Creed"
}];

$scope.createMovie = function(){
$scope.moviesToWatch.push($scope.newMovie);
$scope.newMovie = {};
$scope.newMovieForm = false;
};
$scope.deleteMovie = function(movie){
var movieIndex = $scope.moviesToWatch.indexOf(movie);
$scope.moviesToWatch.splice(movieIndex,1);
}
}]);
})();
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en" ng-app="movieApp">
<head>
<meta charset="UTF-8">
<!-- angular -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.min.js"></script>
<!-- custom script (angular app) -->
<script type="text/javascript" src="app.js"></script>
<title>Augular Practice</title>
</head>
<body ng-controller="MovieCtrl">
<div ng-repeat="movie in moviesToWatch | orderBy:'name'| limitTo:3">
<p>{{movie.name}} <a href="javascript:void(0)" ng-click="deleteMovie(movie)">Delete Pet</a></p>
</div>

<div ngshow="newMovieForm">
<form ng-submit="createMovie()">
<input type="text" ng-model="newMovie.name">
<input type="submit">
</form>
</div>



<div ngPluralize>
<p>{{moviesToWatch.length}} movies to watch</p>
</div>
</body>
</html>