Wednesday, March 29, 2017

Multiple Autocomplete in AngularJS - PHP (Laravel)

Good Morning! I have a Multiple Autocomplete in AngularJS for show user's skills. I have two tables/variables in php, one with the skills that the user choosed ($cont->personal_skills_cat), and other with a list of Skills ($job_categories). I would like to show the skills that the client have in the Multiple Autocomplete, and can to add or remove, from a list of suggestions ($job_categories). It is my code for now. Thanks.

Note: It is in Laravel, so the Blade variables are in and the AngularJS variables are in <% %>

<label>Jobs Categories</label><br>
        <?
        $personal_skills_cat = $jobs_categories;
        $per_skills_cat = json_encode($personal_skills_cat);

        $per_skills_cats = $cont->personal_skills_cat;

        $per_skills_cats = json_decode($per_skills_cats);
        if(isset($per_skills_cats)):
        foreach ($per_skills_cats as $key => $skill_cat): ?>
            <span class="tag"></span>
        <? endforeach;endif;?>
        <br/><br/>

        <multiple-autocomplete id="skills_cat"
                               name="skills_cat"
                               ng-model="skillsFromApi"
                               css-class="someClass"
                               object-property="name"
                               suggestions-arr="">
        </multiple-autocomplete> 
        <input type="hidden" name="skills_cat" value="<%skillsFromApi%>">



via Miguel Herreros Cejas

Advertisement