0
<select name="Connection" class="mdl-button" id="dropConnection" onchange="connectionChange()" ></select> 

The contents are added automatically from JSON response.Thats working fine.

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);
}

after running the page,when I change the dropdown content its showing error

home.html:265 Uncaught ReferenceError: $scope is not defined
    at connectionChange (home.html:265) // above javascript code.
    at HTMLSelectElement.onchange (VM4122 home.html:139)
1
  • 1
    onchange is a native javascript event, not an Angular directive ng-change. And connectionChange is just event handler, not angular $scope function. Commented Sep 11, 2017 at 10:43

1 Answer 1

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)

Looking at this error it can be inferred that you have not injected $scope in your controller. Inject $scope in your controller and it will resolve this error.

Check the link here for knowing how to create a controller in AngularJS properly AngularJS controller

Sign up to request clarification or add additional context in comments.

2 Comments

thank you for the suggestion.. but still getiing 1 error. "connectionChange" is undefined.
try to use ng-change=connectionChange() and define $scope.connectionChange = function(){}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.