Andy Parker
Posts: 0
Joined: Wed Mar 27, 2013 10:21 am

input not binding to scope variable

Hi, I'm using ionic to create an app and have a problem where the input element is not binding the input to a scope variable.

Here's a screenshot of what I've setup:
Image

However, when I display the scope variable in the console, its empty...
I have got the scope variable "trafficFilter" defined as a scope String at the top of the app page.

Can you help please?

Update: So if I place the "trafficFilter" scope variable in a text element, it does show up. The problem I have is that referencing $scope.trafficFilter does not access the value entered.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

input not binding to scope variable

Hello Andy,

Please use the scope variable, based on the Model and it's property in the ng-model attribute. It will allow you to check it's value

Andy Parker
Posts: 0
Joined: Wed Mar 27, 2013 10:21 am

input not binding to scope variable

Sorry Serhii, I don't fully understand you.

I've placed the "trafficFilter" entry in the ng-model of the input element.

Then, in javascript, in a scope function, I reference it as follows:

console.log($scope.trafficFilter);

This doesn't work....am I doing this incorrectly?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

input not binding to scope variable

I meant:

  1. Please create a Model "TrafficFilter" with the property "value"

  2. Use that Model instead of the simple string for the scope variable "trafficFilter"

  3. Use the ng-model property of the input component with the value trafficFilter.value

Andy Parker
Posts: 0
Joined: Wed Mar 27, 2013 10:21 am

input not binding to scope variable

many thanks for this Serhii, works 100%

Return to “Issues”