Sort Angular JS ng-options based on an array

Is there a way to filter ng-options with an array? For example:

<select
    ng-model="currentItem.Community.white_label_id"
    ng-options="whitelabel.WhiteLabel.id as whitelabel.WhiteLabel.name for whitelabel in whitelabels | filter:whitelabel.WhiteLabel.id in currentWhiteLabel.affiliatedids"
>

The currentWhiteLabel.affiliatedids array looks like [73,71]

Any suggestions on how to achieve this?

Answer №1

After some exploration, I came across a solution that involves using ng-repeat within the options. Perhaps this method can provide assistance to others:

option value="whitelabel.WhiteLabel.id" ng-repeat="whitelabel in whitelabels" ng-if="currentWhiteLabel.affiliatedids.indexOf(whitelabel.WhiteLabel.id) != -1">{{whitelabel.WhiteLabel.name}}</option>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adding options to a select input after making an ajax request

I have a dropdown menu. Whenever it is changed, the following code is executed: $('#type').change(function() { var selectedYear = $("#year option:selected").val(); var selectedProduct = $("#product option:selected").val(); var select ...

Issue with primeng dropdown not displaying the selected label

When using the editable dropdown with filter feature from PrimeFaces, I've noticed that selecting an option displays the value instead of the label. https://i.sstatic.net/8YFRa.png Here is the code snippet: <div class="col-md-5 col-xs-1 ...

No data, response or issue received from the Internet API

In my web api project, I have created the following controller: public IEnumerable<Speciality> GetAllSpecialities() { List<Speciality> specialities = null; try { specialities = (new Datatable(Proper ...

Retrieve information from MongoDB and showcase it on the user interface

I am a beginner in NodeJS and server-side technologies, currently working on building a simple app that involves data insertion into a MongoDB database. I am using express-handlebars for this project. While I have successfully saved the data into the data ...

Using react-router to fetch data from the server side

I have successfully implemented React-router server-side rendering in my express app using the following code snippet: app.use((req, res) => { match({ routes, location: req.url }, (error, redirectLocation, renderProps) => { console.log(renderProps) ...

Tips for ensuring the Google Maps API script has loaded before executing a custom directive on the homepage of an Angular website

Issue - I am facing issues with Google Maps autocomplete drop-down not working on my website's main page even after parsing and loading the Google Maps API script. The problem seems to be a race condition on the main page of my website, specifically i ...

Developing a multi-graph by utilizing several JSON array datasets

Currently exploring D3 and experimenting with creating a multi-line graph without utilizing CSV, TSV, or similar data formats. The key focus is on iterating over an array of datasets (which are arrays of objects {data:blah, price:bleh}). I am trying to a ...

resetting form with submission action

I am working with the following code snippet: <form id="form-lecturerInfo-setup"> ... <input type="submit" value="Submit" /> <input type="reset" value="Reset" /> </form> <script> $('#form-lecturerInfo-se ...

Tips for shuffling questions within arrays

var quiz = [ { "question" : "Q1: What is the greatest invention of all time?", "choices" : [ "Wheel", "Electricity", ...

Calculate the sum of elements with JavaScript

I am working with an array where each element is an object that also contains an array. My goal is to calculate the sum of all items in the nested arrays. Here is the approach I have attempted: function getSum(total, item) { return total + item; } v ...

Prevent tooltip text from appearing when a button is disabled in an angular application

As a beginner in UI development, I have a requirement for my Angular application. I need to enable and disable a button based on certain conditions. The tricky part is that I want to display a tooltip only when the button is enabled. I have managed to chan ...

TypeScript combined with Vue 3: Uncaught ReferenceError - variable has not been declared

At the start of my <script>, I define a variable with type any. Later on, within the same script, I reference this variable in one of my methods. Strangely, although my IDE does not raise any complaints, a runtime error occurs in my console: Referenc ...

Verify whether a specific point in time falls within the same week as any date string within an array of date strings

I am working on my backbone-app copyCLDRView and I am trying to replicate weeks along with their components and data. In simpler terms, I want to "copy one week and all its models into another week." My goal is to check if the target week has at least one ...

Angular AutoComplete feature does not accurately filter the list items

I need to implement an auto-complete feature for the county field due to a large number of items in the list causing inconvenience to users who have to scroll extensively. Currently, there are two issues with the code. The first problem is that although t ...

`NodeJS and ExpressJS: A guide on accessing a remote phpMyAdmin server`

I am in the process of setting up a GraphQL server and facing an issue with connecting to a remote phpMyAdmin server provided by a friend. The error message I am encountering is: Error: getaddrinfo ENOTFOUND 54.193.13.37/phpmyadmin 54.193.13.37/phpmyadmi ...

Solving Promises with Arrays in JavaScript

Currently, I am working on a project and facing an issue that I need help with. Let me give you some background on what I am trying to achieve. First, I am making concurrent API calls using Axios in the following manner: const [...result] = await Promise. ...

What is the process for deselecting text from a text field?

After performing a search and displaying the results on my search form, I've noticed that the text query in the textfield is being marked as selected text even though I don't want it to be. How can I prevent this? Fiddle 1) What is the best app ...

Unable to assign a value to input in Knockout.js app using Selenium webdriver

Utilizing Selenium driver and Capybara to interact with an external site that is coded on Knockout JS. The objective is to input a value. Sounds simple, right? Here is the HTML for this particular input: <input data-bind="value: $root.data.location.us ...

How to execute an object function in TypeScript only if it is defined

Currently, I am working on creating a binary search tree class in Typescript as part of my learning journey with the language. My aim is to incorporate generics into this exercise. In the process of implementing algorithms within the class, I have encount ...

Send the error message to the ajax error handling function

Utilizing jQuery's ajax, I am invoking a controller method on the client side. $.ajax({ url: "/Services/VendorServices.asmx/SendVendorRequestNotifications", type: 'POST', contentType: "application/json", dataType: "json", ...