0

I don't know what I am doing wrong here, can anyone see what I am doing wrong? I just want to pass my form inputs (in this case a date picker) to a controller function, but everything I try to access just shows up as undefined!

Here is my form

<form ng-submit="showRefinedGameMarkers(refinements)">
    <div class="list">
      <div class="datepickers">
      From Date:
      <label class="item item-input">
        <input ng-controller="DatepickerCtrl"
        type="text" 
        placeholder="Pick date" 
        ng-model="refinements.from_datepicker" 
        name="from_datepicker" 
        ng-click="opendateModal()" 
        readonly>
      </label>
      </div>

Here is my controller class

.controller('MapController', function($scope, $ionicLoading, gameFactory, $compile) {

  $scope.showRefinedGameMarkers = function(refinements) {
    $scope.refinements = refinements;
    console.log($scope.refinements);
    ...
    }
})

Everything I have tried is just showing up as undefined, so annoying! Any help would be greatly appreciated thank you

1
  • 2
    Add $scope.refinements = {}; at the top of your controller. Commented Feb 11, 2015 at 22:00

2 Answers 2

1

You dont need pass refinements to your submit function, because its bound using ng-model and angular will change $scope.refinements for you.

Also,you need to initialize your refinements variable in your controller.

$scope.refinements = {}
Sign up to request clarification or add additional context in comments.

1 Comment

I put $scope.refinements = {} at the top of my controller, but everything I try is still show as being undefined. Is $scope.refinements = refinements; console.log($scope.refinements); the right syntax even? Thanks
1

Add $scope.refinements = {}; at the top of your controller.

1 Comment

I put $scope.refinements = {} at the top of my controller, but everything I try is still show as being undefined. Is $scope.refinements = refinements; console.log($scope.refinements); the right syntax even? Thanks

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.