-
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
7 changed files
with
169 additions
and
27 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
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,22 @@ | ||
(function() { | ||
|
||
var module = angular.module("atTheMovies"); | ||
module.directive("alert", function() { | ||
|
||
return { | ||
restrict: "EA", | ||
transclude: true, | ||
scope: { | ||
type: "@", | ||
reason: "=", | ||
close: "&" | ||
}, | ||
replace: true, | ||
controller: function(scope, element, attributes) { | ||
|
||
}, | ||
templateUrl: "views/alert.html" | ||
}; | ||
}); | ||
|
||
}()); |
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,17 +1,23 @@ | ||
(function() { | ||
|
||
var module = angular.module("atTheMovies", []); | ||
var module = angular.module("atTheMovies", ["atTheMovies.data"]); | ||
|
||
module.config(function($httpProvider) { | ||
|
||
module.config(function (movieServiceProvider) { | ||
movieServiceProvider.setRootUrl("/api/movies"); | ||
}); | ||
|
||
module.config(function($provide) { | ||
$provide.decorator("$exceptionHandler", function($delegate) { | ||
return function(reason, cause) { | ||
$delegate(reason, cause); | ||
}; | ||
}); | ||
}); | ||
|
||
module.run(function($rootScope) { | ||
$rootScope.appConfig = { | ||
version: "v1.1" | ||
}; | ||
|
||
|
||
}); | ||
|
||
}()); |
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,18 +1,79 @@ | ||
(function() { | ||
(function () { | ||
|
||
var movieService = function($http) { | ||
var module = angular.module("atTheMovies.data", []); | ||
module.config(function ($provide) { | ||
$provide.provider("movieService", function () { | ||
|
||
return { | ||
getAll : function() { | ||
return $http.get("/api/movies"); | ||
}, | ||
save : function(movie) { | ||
return $http.put("/api/movies", movie); | ||
} | ||
}; | ||
}; | ||
var url; | ||
|
||
var module = angular.module("atTheMovies"); | ||
module.factory("movieService", movieService); | ||
this.setRootUrl = function (newUrl) { | ||
url = newUrl; | ||
}; | ||
|
||
}()); | ||
this.$get = function ($http, $q, $timeout) { | ||
|
||
var movies = null; | ||
|
||
return { | ||
|
||
getAll: function () { | ||
|
||
if (movies) { | ||
return $q.when(movies); | ||
} else { | ||
|
||
return $http.get(url) | ||
.then(function (response) { | ||
movies = response.data; | ||
return movies; | ||
}); | ||
} | ||
}, | ||
save: function (movie) { | ||
return $http.put(url, movie); | ||
} | ||
}; | ||
}; | ||
|
||
}); | ||
}); | ||
}()); | ||
|
||
|
||
|
||
//(function () { | ||
// var movieService = function ($http, $q, $timeout) { | ||
// var movies = null; | ||
// return { | ||
// getAll: function () { | ||
// if (movies) { | ||
// return $q.when(movies); | ||
// } else { | ||
// return $http.get("/api/movies") | ||
// .then(function(response) { | ||
// movies = response.data; | ||
// return movies; | ||
// }); | ||
// } | ||
// }, | ||
// save: function (movie) { | ||
// return $http.put("/api/movies", movie); | ||
// } | ||
// }; | ||
// }; | ||
// var module = angular.module("atTheMovies"); | ||
// module.factory("movieService", movieService); | ||
//}()); | ||
|
||
|
||
//getMovie: function (id) { | ||
// var deferred = $q.defer(); | ||
// $timeout(function() { | ||
// if (id < 0) { | ||
// deferred.reject("Could not fetch the movie"); | ||
// } else { | ||
// deferred.resolve({ title: "This movie came from a promise" }); | ||
// } | ||
// }, 2000); | ||
// return deferred.promise; | ||
//}, |
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,6 @@ | ||
<div class="alert alert-{{type}}"> | ||
<button class="close" ng-click="close()">x</button> | ||
<div ng-transclude></div> | ||
<input type="text" ng-model="reason" /> | ||
{{ reason }} | ||
</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