I have a basic click to edit span field in my code, which prompts an input box and a couple of buttons:
<span ng-click="editField()" ng-if="edit === false">Your text to edit</span>
<div ng-if="edit === true">
<input type="text" ng-bind="data.field" value="Your text to edit" />
<button type="submit" class="btn btn-primary" ng-click="update(data.field, 'somename')"><span class="glyphicon glyphicon-ok"></span></button>
<button type="button" class="btn btn-default" ng-click="cancelEdit()"><span class="glyphicon glyphicon-remove"></span></button>
</div>
When the user saves, the update
function is called. However, the issue I'm having is that how do I send whatever text the user inputs, towards my angular logic, without settings the text values in an object at the start of the controller?
Heres an example: http://jsfiddle.net/43GUa/1/
Basically it prints in the console: undefined + somename
How do I get that undefined
to the text in the input field? I can't use ng-model
since I'm unable to declare my object data(?) in my controller.
Cheers