0

I'm using angular js. When I have a snippet that I put in ng-include instead of outright writing the html to the same file, the former doesn't seem to pick up my bindings for my input fields.

In other words, if the following snippet:

<form name="pickupForm" ng-submit="completeCheckoutPickup()" novalidate>
 <div class="row checkout-input">
   <div class="col-sm-12">
     <div class="title">
    PICK UP DATE & TIME
     </div>
     <span class="glyphicon glyphicon-calendar date-icon-color"></span>
     <input type="date" ng-model="userDate" required>
     <span class="glyphicon glyphicon-time date-icon-color"></span>
     <input type="time" ng-model="userTime" required>
    </div>
   </div>
</form>

is included as

<div ng-include src="'/templates/account/checkout/checkout.pickup.desktop.html'"></div>

The angularjs bindings for the ng-model stop working.

Any ideas?

enter code here
mike gold
  • 1,551
  • 12
  • 12
  • It's possible the following answers this question :-) http://stackoverflow.com/questions/11412410/angularjs-losing-scope-when-using-ng-include – mike gold Dec 29 '14 at 17:05
  • so in more detail. It's not that the bindings aren't working, its that ng-include creates a child scope, so that scope is unrelated to the parent scope. The way to handle the issue, is that in the submit of the form, use the this pointer instead of $scope. because this is always referring to the current scope. This was answered by the stack overflow link in this comment, but the thread may help someone who thinks their bindings are broken instead of their scope. – mike gold Dec 29 '14 at 17:13

0 Answers0