0

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>
2
  • 1
    You don't want to use a controller? If you really don't, try ng-app="". And see how that goes Commented Oct 9, 2014 at 18:35
  • I was trying to break it down into the easiest repro Commented Oct 9, 2014 at 20:25

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.