Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript $scope:scope在angularjs中是什么意思_Javascript_Angularjs - Fatal编程技术网

Javascript $scope:scope在angularjs中是什么意思

Javascript $scope:scope在angularjs中是什么意思,javascript,angularjs,Javascript,Angularjs,我正在学习Angularjs的官方教程,我被困在第二步 这里有一个片段,我不理解$scope:scope的含义 describe('PhoneListCtrl', function(){ beforeEach(module('phonecatApp')); it('should create "phones" model with 3 phones', inject(function($controller) { var scope = {}, ctrl =

我正在学习Angularjs的官方教程,我被困在第二步

这里有一个片段,我不理解
$scope:scope
的含义

describe('PhoneListCtrl', function(){

  beforeEach(module('phonecatApp'));

  it('should create "phones" model with 3 phones', inject(function($controller) {
    var scope = {},
        ctrl = $controller('PhoneListCtrl', {$scope:scope});

    expect(scope.phones.length).toBe(3);
  }));

});

我猜它是一个键值对,但是作用域被初始化为
{}
,为什么它的成员元素是
phones
?有人能解释一下这是什么意思吗?

你在写测试。这一行:

ctrl = $controller('PhoneListCtrl', {$scope:scope});
将作用域作为空对象注入到实际控制器中。您的测试确保控制器在示波器上设置长度为3的
phones
属性