Created
May 19, 2014 22:11
-
-
Save evan-007/023d88bc3cae9143adb1 to your computer and use it in GitHub Desktop.
ng
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
//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"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.