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
var app = angular.module('GalleryApp', ['ngRoute']); | |
app.config(function ($routeProvider) { | |
$routeProvider | |
.when('/', { | |
controller: 'HomeController', | |
templateUrl: 'views/home.html' | |
}) | |
.when('/photos/:id', { | |
controller: 'PhotoController', | |
templateUrl: 'views/photo.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
// 'books' is a service for fetching data about books | |
app.controller('ChapterController', ['$scope', 'books', '$routeParams', function($scope, books, $routeParams) { | |
books.success(function(data) { | |
$scope.book = data[$routeParams.bookId]; | |
$scope.chapter = $scope.book.chapters[$routeParams.chapterId]; | |
// If there no more chapters left, go back to the bookshelf view | |
if($routeParams.chapterId >= $scope.book.chapters.length - 1) { | |
$scope.nextChapterIndex = "#"; | |
} |
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
app.factory('forecast', ['$http', function($http) { | |
return $http.get('https://s3.amazonaws.com/codecademy-content/courses/ltp4/forecast-api/forecast.json') | |
.success(function(data) { | |
return data; | |
}) | |
.error(function(err) { | |
return err; | |
}); | |
}]); |
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
var myApp = angular.module("MyApplication", ['ngRoute', 'leaflet-directive']); | |
myApp.configuration(...); |
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
app.directive('appInfo', function() { | |
return { | |
restrict: 'EA', // E -element, A - attribute, C - class, M - comment | |
scope: { | |
info: '=' // attribute of this directive | |
}, | |
templateUrl: 'js/directives/appInfo.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
/** | |
* Gets a movie object from the database. | |
* | |
* @param movieId - Movie identifier string. | |
* @return Document object or null. | |
*/ | |
public Document getMovie(String movieId) { | |
if (!validIdValue(movieId)) { | |
return null; | |
} |