Rich MacKinnon
Rich MacKinnon

Reputation: 13

Angular, ng-init doesn't initialize

Trying to initial a text box with ng-init but the text box is always blank?

<form  ng-app="TheApp" ng-init="email='[email protected]'">
    <div>
        <label>email: </label>
        &nbsp;<input type="text" ng-model="email">
    </div>
</form>

Upvotes: 0

Views: 520

Answers (1)

Owen
Owen

Reputation: 718

I don't know if you're starting your angular correctly. Dropping ="TheApp" makes this work. See this fiddle.

In your app.js, are you defining your angular module as TheApp? i.e. angular.module('TheApp', [])

<form  ng-app ng-init="email = '[email protected]'">
<div>
    <label>email: </label>
    &nbsp;<input type="text" ng-model="email">
</div>
</form>

Upvotes: 2

Related Questions