I would like to understand how to do the following, they asked me to try and create a function in the controller instead of writing the code in the view.
The code is:
<div class="row">
<div class="col-xs-12 max300"
uib-dropdown is-open="vm.descriptionDropdownOpen">
<textarea name="description" class="form-control"
ng-model="vm.presence.description"
ng-click="vm.toggleDescriptionDropdown()"
autofocus>
</textarea>
<ul id="descriptionDropdown" uib-dropdown-menu>
<li ng-repeat="descr in vm.loadedDescriptions"
ng-click="vm.presence.description = descr.text;
vm.descriptionDropdownOpen = false;">
{{descr.text}}
</li>
</ul>
</div>
</div>
so basically this creates a text box, and when you click on it, a dropdown menu will appear, and if you click on a string of the dropdown menu, that string will be put in the text box.
What I need to do is to create a function that will be put in the controller, so we can just call that function in the view and keep the code nicer.
This function just needs to do the last part of the code I posted above, take the string I click on from the dropdown menu and put it in the text box!
It's really simple but as I'm learning I'm not that sure on how I should write it
setDescription(text: string) {
// code should go here.
}
Sorry for this stupid question, just wanna be sure to understand correctly what I am doing! thank you
ng-click="vm.presence.description = descr.text;