<select name="Connection" class="mdl-button" id="dropConnection" onchange="connectionChange()" ></select>
内容是从JSON响应自动添加的。工作正常。
function connectionChange()
{
var sel = document.getElementById("dropConnection");
var connectionName = sel.options[sel.selectedIndex].text;
$scope.connectionDetail = response.data.message.connectionDetailses.filter(det => det.connectionId === connectionName);
console.log($scope.connectionDetail);
}
运行页面后,当我更改下拉内容时显示错误
home.html:265 Uncaught ReferenceError: $scope is not defined
at connectionChange (home.html:265) // above javascript code.
at HTMLSelectElement.onchange (VM4122 home.html:139)
答案 0 :(得分:1)
home.html:265 Uncaught ReferenceError: $scope is not defined
at connectionChange (home.html:265) // above javascript code.
at HTMLSelectElement.onchange (VM4122 home.html:139)
查看此错误可以推断您未在控制器中注入$scope
。在控制器中注入$scope
,它将解决此错误。
检查此处的链接,了解如何正确地在AngularJS中创建控制器AngularJS controller