In my HTML, I have a select box with options generated from an ng-repeat.
<select ng-model="pageId" ng-change="setFacebookPage()">
<option ng-repeat="page in pages" ng-value="page.id"> {{page.name}}</option>
</select>
Everything seems to be working correctly as the values and options are displayed properly. However, when trying to access the value of pageId in the function setFacebookPage()
, it turns out to be undefined within the controller.
$scope.setFacebookPage = function(){
console.log("setFacebookPage", $scope.pageId);
}
Interestingly, if I change the value of pageId, I can see its new value using {{pageId}}.
I attempted passing it as a parameter in the function like setFacebookPage(pageId)
, but that also resulted in an undefined value.
What could be causing this issue and how can I go about solving it?