I have following span that I am using as a text input.
<span ng-model="sampleText" style="width:100px; padding:20px, 100px;" class="TextBox"></span>
Reason why I am using span instead of "input" or "textarea" is so that I have one box which can keep adding rows as I hit enter. This is more elegant way than showing a big box of textarea. But problem I am facing is how do i bind the text that has been entered to the ng-model. Maybe using ng-init? Please let me know how to bind the text that has been entered to the "sampleText" Thanks
The ngModel
directive itself doesn't do much. It provides a controller that is used by other directives, like input
(yes, input
is a directive). That means you have to write your own one.
But you are lucky, because the documentation for the ngModelController has an example that's almost identical to yours.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.