Ionic popup $scope.var returned undefined?


#1
$scope.openAddNewSubPopup = function(){
       var addNewSub = $ionicPopup.show({
       scope: $scope,
       template: '<label class="item item-input"><input type="text" model="addNewSubItemValue"></label>'
     });

    addNewSub.then(function(res) {
       
         console.log($scope.addNewSubItemValue)
     });

Anyone have idea why I’m getting undefined here? when I tried to do {{addNewSubItemValue}} in the template, it did bind well.


#2

As it says in the documentation, you’ll want to define a $scope.data = {} before your $ionicPopup.show(), then have ng-model="data.addNewSubItemValue. Check out the docs :smile: