Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.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
Angularjs 角镜奇异性_Angularjs - Fatal编程技术网

Angularjs 角镜奇异性

Angularjs 角镜奇异性,angularjs,Angularjs,我是个新手,希望有人能帮我 我在控制器中的$watch内具有以下功能: AppServices.createComponentObj($scope, value.component_id) .then(function(data){ $scope.components = {}; $scope.components.component_type_one = []; $scope.components.component_type_two = [];

我是个新手,希望有人能帮我

我在控制器中的$watch内具有以下功能:

    AppServices.createComponentObj($scope, value.component_id)
    .then(function(data){
    $scope.components = {};
    $scope.components.component_type_one = [];
    $scope.components.component_type_two = [];
    $scope.components.component_type_three = [];

    switch (data.type){
        case "Type One":
            $scope.components.component_type_one.push(data);
        break;

        case "Type Two":
            $scope.components.component_type_two.push(data);
        break;

        case "Type Three":
            $scope.components.component_type_three.push(data);
        break;
    }
})
.then(function(){
     console.dir($scope.components.component_type_one);
});
我得到一个错误,说“push”不能在未定义的情况下调用

关于$scope有什么我不理解的吗


提前感谢。

您是否尝试过调试?听起来
数据
未定义。请发布
AppServices
是的,我已经浏览了Chrome调试器,仍然感到困惑,“数据”作为组件对象正确返回。复制粘贴了代码。听起来好像有一些打字错误。。。您可以展示更广泛的背景(最好是在plunkr中)?请显示准确的错误堆栈(可能是关于其他的
推送
)?