0

I have a form that is inserted via ng-include, but it doesn't work. If I manually paste in the html template from the ng-include src (instead of using ng-include), then it works fine. Is there something about ng-include that disables forms?

<div ng-include src="'views/login_form.html'"></div>

login_form.html:

<form ng-submit="loginUser()">
    <table>
        <tr>
            <td class="login_input_field v_align_top">
                <input type="text" name="email" ng-model="email">
            </td>
            <td class="login_input_field">
                <input type="password" name="pass" ng-model="password">
            </td>
            <td class="login_button_container">
                <button type="submit" id="login" name="login">Login</button>
            </td>
        </tr>
    </table>
</form>

What am I missing?

Chris Paterson
  • 1,129
  • 5
  • 21
  • 31
  • You're probably seeing the same problem as described here: [AngularJS - losing scope when using ng-include][1] [1]: http://stackoverflow.com/a/11417113/584846 – Brent Washburne Jan 22 '14 at 00:45

1 Answers1

0

Try breaking out the loginUser() into its own subcontroller.

That way your function will be in the same $scope.

<div ng-controller="LoginUserController">
  <div ng-include src="'views/login_form.html'"></div>
</div>
willoller
  • 7,106
  • 1
  • 35
  • 63