This code is from https://docs.angularjs.org/tutorial/step_02. I was just wondering why the scope.phones.length property is 3 instead of 0, since scope is an empty object. I am not sure what this line is doing:
var ctrl = $controller('PhoneListController', {$scope: scope});
it looks like its setting the $scope in the controller to the empty scope object.
describe('PhoneListController', function() {
beforeEach(module('phonecatApp'));
it('should create a `phones` model with 3 phones', inject(function($controller) {
var scope = {};
var ctrl = $controller('PhoneListController', {$scope: scope});
expect(scope.phones.length).toBe(3);
}));
});
$controlleris a service which calls a controller. in this case it callsPhoneListController. In this tutorial, at that point there is a$scope.phonesarray with 3 elements insidePhoneListController.{$scope: scope}$scopedependency inside controller. it you seePhoneListController, it has $scope as a dependencyscope.phones = [phone1, phone2, phone3]is done inside the controller right? Anyway, you can post it as an answer and I'll accept it.