Skip to content

Instantly share code, notes, and snippets.

@evan-007
Created May 19, 2014 22:11
Show Gist options
  • Save evan-007/023d88bc3cae9143adb1 to your computer and use it in GitHub Desktop.
Save evan-007/023d88bc3cae9143adb1 to your computer and use it in GitHub Desktop.
ng
//code school approach
app.controller('LibraryController', function(){
this.books = getBooks //some function that gets an array
});
//in the view
<div ng-controller="LibraryController as libraryCtrl">
<ul>
<li ng-repeat="book in libraryCtrl.books">
//everyone else uses scope?
app.controller('LibraryController', function($scope){
$scope.books = getBooks //some function that gets an array
})
//in the view
<div ng-controller="LibraryController">
<ul>
<li ng-repeat="book in books">
@ninjasort
Copy link

It's essentially the same object, but $scope is the way Angular keeps track of the context of the controller. I would use $scope because it's the actual object that angular provides and I believe it contains underlying functionality and methods to manage itself internally to the Angular app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment