Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angularjs

I'm 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); 
};

By using a callback function, I'm trying to get the selected object value (as explained in angucomplete-alt documentation), but I receive the follwing error :

Error: [$compile:nonassign] Expression 'addSkill1()' used with directive 'angucompleteAlt' is non-assignable!

like image 966
Hawk-Eye Avatar asked Apr 15 '15 15:04

Hawk-Eye


1 Answers

I digged the example from: Angucomplete Alt and I find out that you must provide the selected-object like this, even if It's a callback function:

<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 receive the selected item as parameter:

$scope.addSkill = function (selected) {
    console.log(selected); 
};
like image 93
Fals Avatar answered Oct 12 '22 19:10

Fals