我有以下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:无法设置未定义脚本的属性‘’
发布于 2018-07-25 03:22:52
我认为你需要重新审视一下你是如何使用括号表示法的。我认为您可能正在为您的角色分配寻找$scope.repos[‘template’] = template
和类似的东西。存储在template
和role
中的数据的形状是什么
https://stackoverflow.com/questions/51505954
复制相似问题