收到TypeError:无法设置未定义的属性“脚本”

时间:2018-07-24 19:09:56

标签: angularjs typeerror

我有以下AngularJS代码:

HTML:

<input type="text" class="form-control" id="repoInput" style="margin: 10px 0 10px 0" placeholder="Stored Procedures" ng-model="procedureInput" uib-typeahead="key for key in getScripts(selected.branchClone, selected.type) | filter:$viewValue | limitTo:10" typeahead-on-select='addStoredProcedure($item, selected);procedureInput = "";' typeahead-loading="templateLoading" typeahead-wait-ms="100" />

$scope.getScripts = function (repo, template) {
items.then(function (payload) {
            $scope.repos[template] = template;
            $scope.repos[template][repo] = repo;
            console.log($scope.repos[template]);
            console.log(repo);
            console.log($scope.repos[template][repo]);
            $scope.repos[template][repo]["scripts"] = payload.data.value;
            deferred.resolve(payload.data.value
                .map(function (x) {
                    return x["path"];
                }));
        });
}

我确实有template变量和repo变量的值。但是,仍然

出现错误

$scope.repos[template][repo]["scripts"] = payload.data.value;

TypeError:无法设置未定义的属性“脚本”

1 个答案:

答案 0 :(得分:0)

我认为您需要重新使用括号表示法。我认为您可能正在寻找SQL> with test (col) as 2 (select 'a123bcd-e2343fg-hij-dfgh' from dual) 3 select substr(col, instr(col, '-') + 1) result 4 from test; RESULT ---------------- e2343fg-hij-dfgh SQL> 和类似的角色分配。 $scope.repos[‘template’] = templatetemplate中存储的数据的形状是什么?