This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
controller.js
64 lines (50 loc) · 1.72 KB
/
controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
(function() {
'use strict';
var app = angular.module('MovieDatabase');
app.controller('AppController', function($scope) {
$scope.title = 'The Movie Database';
});
app.controller('WelcomeController', function() {
});
app.controller('MoviesListController',
function($scope, $location, movieList) {
$scope.movies = movieList.data;
$scope.add = function () {
$location.path('/movies/new');
};
});
app.controller('MoviesAddController',
function($scope, $http, $location) {
$scope.movie = {};
$scope.save = function (movie) {
$http.post('/movies', movie)
.success(function(res) {
$location.path('/movies/' + res.id);
});
};
});
app.controller('MovieDetailController',
function($scope, $http, $location, movie) {
$scope.movie = movie.data;
$scope.delete = function () {
$http.delete('/movies/' + $scope.movie.id).success(function (res) {
$location.path('/movies');
});
};
});
app.controller('MovieEditController',
function($scope, $http, $location, movie) {
$scope.movie = movie.data;
$scope.save = function () {
$http.put('/movies/' + $scope.movie.id, $scope.movie)
.success(function (res) {
$location.path('/movies/' + $scope.movie.id);
});
};
});
function ProblemController($scope, $location) {
$scope.culprit = $location.search().culprit || 'unknown beast';
}
app.controller('NotFoundController', ProblemController);
app.controller('ErrorController', ProblemController);
})();