How to use the callback function on the selected-object attribute angucomplete-alt?

I am currently working on the following code:

<angucomplete-alt id="skill1" selected-object="addSkill1()" remote-url="@Url.Action("GetSkills", "ManageMission")/?query=" title-field="Name" minlength="1" match-class="angucomplete-match" input-class="form-control" template-url="@Url.Content("~/Templates/angucomplete-alt.html")"></angucomplete-alt> 
 $scope.addSkill1 = function () { console.log(arguments); }; 

Using the callback function, I am trying to get the selected value of an object ( as explained in the angucomplete-alt documentation ), but I will get the following error:

Error: [$ compile: nonassign] The expression 'addSkill1 ()' used with the 'angucompleteAlt' directive cannot be assigned!

+6
source share
1 answer

I dug up an example from Angucomplete Alt , and I found out that you have to provide a selected-object like this, even if it's a callback :

 <angucomplete-alt id="skill1" selected-object="addSkill" remote-url="@Url.Action("GetSkills", "ManageMission")/?query=" title-field="Name" minlength="1" match-class="angucomplete-match" input-class="form-control" template-url="@Url.Content("~/Templates/angucomplete-alt.html")"></angucomplete-alt> 

And the callback method should get the selected element as a parameter:

 $scope.addSkill = function (selected) { console.log(selected); }; 
+8
source

Source: https://habr.com/ru/post/985197/


All Articles