-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
47 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
var HelloController = function($scope) { | ||
|
||
$scope.showMessage = function() { | ||
$scope.message = "Hello, World!"; | ||
}; | ||
|
||
$scope.saveMessage = function() { | ||
$scope.alert = "Saved..."; | ||
}; | ||
(function() { | ||
|
||
}; | ||
var HelloController = function ($scope) { | ||
|
||
$scope.showMessage = function () { | ||
$scope.message = "Hello, World!"; | ||
}; | ||
|
||
var MoviesController = function($scope) { | ||
$scope.saveMessage = function () { | ||
$scope.alert = "Saved..."; | ||
}; | ||
|
||
var movies = [ | ||
{ title: "Star Wars", length: 120, released: 1981 }, | ||
{ title: "Top Gun", length: 90, released: 1984 }, | ||
{ title: "Hot Shots", length: 89, released: 1986 } | ||
]; | ||
}; | ||
|
||
$scope.movies = movies; | ||
var module = angular.module("atTheMovies"); | ||
module.controller("HelloController", HelloController); | ||
}()); | ||
|
||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(function() { | ||
|
||
var MoviesController = function ($scope, movieService) { | ||
|
||
var onMovies = function(response) { | ||
$scope.movies = response.data; | ||
}; | ||
|
||
var onError = function(reason) { | ||
$scope.error = "There was a problem"; | ||
}; | ||
|
||
movieService.getAll() | ||
.then(onMovies, onError); | ||
|
||
|
||
$scope.increase = function (movie) { | ||
movie.rating += 1; | ||
}; | ||
|
||
$scope.decrease = function (movie) { | ||
movie.rating -= 1; | ||
}; | ||
}; | ||
|
||
var module = angular.module("atTheMovies"); | ||
module.controller("MoviesController", | ||
["$scope", "movieService", MoviesController]); | ||
|
||
}()); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(function() { | ||
|
||
var module = angular.module("atTheMovies", []); | ||
|
||
module.config(function($httpProvider) { | ||
|
||
}); | ||
|
||
module.run(function($rootScope) { | ||
$rootScope.version = "v1.0"; | ||
}); | ||
|
||
}()); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(function() { | ||
|
||
var movieService = function($http) { | ||
|
||
return { | ||
getAll : function() { | ||
return $http.get("/api/movies"); | ||
} | ||
}; | ||
}; | ||
|
||
var module = angular.module("atTheMovies"); | ||
module.factory("movieService", movieService); | ||
|
||
}()); |