Skip to content

Instantly share code, notes, and snippets.

@mbranicky
Last active August 29, 2015 14:27
Show Gist options
  • Save mbranicky/1a21868e22a918abff50 to your computer and use it in GitHub Desktop.
Save mbranicky/1a21868e22a918abff50 to your computer and use it in GitHub Desktop.
Controller (basic examples)
// '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 = "#";
}
});
}]);
app.controller("MainController", ['$scope', 'places', function($scope, places) {
$scope.mapCenter = {
lat: 40.741934,
lng: -74.004897,
zoom: 17
};
// use the places service:
places.success(function(data) {
$scope.geodata = data;
$scope.mapMarkers = geodataToMarkers($scope.geodata);
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment