List of selectable options and interactive map feature in Angular.js for easy filtering

Seeking assistance on a filtering issue I am facing. I have a list of results that need to be filterable by both a Select field, with predefined 'region' values, and a clickable SVG map with A tags linking to #region_values. The values on the map and in the Select field will match. Despite hours of searching online, I haven't found a solution.

How can I set up both as filters for the same list?

Below is the functioning list generator:

<div class="results" id="goto" ng-controller="listCtrl">
    <input type="text" ng-model="filterText" />
    <div class="list">
        <div class="item" ng-repeat="item in items">
            <div class="columns image">
                <img src="images/misc/{{ item.image }}" alt="{{ item.name }}">
                <a target="_blank" class="button green-button" href="{{ item.url }}">{{ item.button }}</a>
            </div>
            <div class="columns copy">
                <div class="result"><span class="place">{{ $index+1 }}</span>{{ item.vote }} de los votos</div>
                <h2>{{ item.name }}</h2>
                <p>{{ item.desc }}</p>
                <p>{{ item.region }}</p>
            </div>
        </div>
    </div>
</div>

here is the controller :

function listCtrl($scope) {

    $scope.items = [{
            "name": "City Name",
            "desc": "City Description",
            "vote": "56,4%",
            "image": 'image.jpg',
            "url": 'http://sample.url',
            "button": "Button Text",
            "region": "Some Region"
        }
    ];
}

Map markup:

<svg>
    <g>
        <a id="s40" xlink:href="#region1">
            <path> ...</path>
        </a>
        <a id="s40" xlink:href="#region2">
            <path> ...</path>
        </a>
    </g>
</svg>

Select field code:

<select>
   <option value="region1">Region1</option>
   <option value="region2">Region2</option>
</select>

Your help is much appreciated!

Answer №1

Utilizing a text box for searching and filtering is essential in web development. If you need guidance on how to implement this functionality, check out this Plnkr example: http://plnkr.co/edit/EjzcOG?p=preview

HTML

<label>
 Search Text: <input ng-model="val" ng-keyup="search(val)" ng-keydown="search(val)">
</label><br>
<div data-ng-repeat="customer in displayCustomers">
<span>{{customer}}</span>

Script

$scope.customers = ['bob', 'sean', 'rocky', 'john', 'ali', 'isak', 'isthiqui', 'ram', 'acheer', 'shrish'];

 $scope.displayCustomers = $scope.customers;

 $scope.search = function (searchTerm) {
            $scope.displayCustomers = $filter('filter')($scope.customers, searchTerm);
};

Answer №2

The issue was resolved by including the ng-click="catFilter='regionname'" attribute to the specific links that needed to manipulate the select field based on the chosen region name.

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

Steps to prevent specific links from being clickable in React Native's webview component

In my React Native app, I am utilizing the react-native-webview component to display blog posts. The code I have implemented is straightforward, but my goal is to restrict the webview to only show content from the blog section of the website, preventing us ...

The functionality of $(window).load doesn't appear to be functioning correctly in Firefox

I have a piece of code that needs to run only after the website content is fully loaded, so I have placed it inside the window load function like this: $(window).load(function() { //some stuff happens }); This code works perfectly in Safari and Chrom ...

jQuery - Password Validation

I need help using jQuery to validate two password fields against each other. Below is the code snippet I am currently using: jQuery('#settingsForm').validate( rules : { npassword : { }, pass_check : { equ ...

utilizing AJAX to retrieve scripts from WITHIN my own domain

In the realm of ajax scripts, I encounter a scenario where referencing something within the same domain requires passing HTML and associated javascript. Due to it being a non X-domain setup, I anticipate that this could be achievable. The aim here is to fe ...

Suggestions on coloring polyline segments according to the density of neighboring segments surrounding the specific polyline segment

Apologies for the lengthy title, but I am interested in developing a polyline heatmap that changes color based on the number of lines within a certain proximity. Here is an example of what I have in mind: https://i.sstatic.net/W2lox.jpg Are there any inn ...

Conquering cross-origin resource sharing (CORS) using XMLHttpRequest without relying on JSONP

Appreciate your time in reading this inquiry! For the past few days, I've been grappling with an AJAX request issue. Despite scouring through numerous answers on Stack Overflow, I'm still unable to find a resolution. Any assistance would be grea ...

Switch out the image in the dropdown and update the button once it is selected

In this scenario, I am looking to dynamically change the image in a button dropdown when it is clicked. The goal is for the dropdown image to swap and replace with the actual one upon clicking. For reference, here's the fiddle: https://jsfiddle.net/32 ...

Angular JS: Changing Byte Array into an HTML File

I created an HTML file using ASPOSE workbook and stored it in a memory stream in C#. Now, I am trying to show this HTML file in an Angular JS environment within the Div element. C# Snippet: wb.Save(htmlMemoryStream, new HtmlSaveOptions() { IsExportComment ...

Run a .jar file within Spoon (Pentaho Kettle)

I am trying to run a java jar file from Spoon. The jar file contains a single class named "Limpieza" within the package com.overflow.csv.clean. I would like to be able to execute this class with or without parameters. I have placed the jar file in the d ...

What's the best way to use JavaScript to obtain the width of a 'css-pixel' based on a media query?

While there have been discussions on how to determine device sizes using media queries like Twitter Bootstrap, I am looking for a reliable way to achieve the same output using JavaScript. Specifically, I want to get the CSS media query pixel number rather ...

Exploring the Power of JQuery and Iterating with For-

I'm currently facing a small issue with my code. I need to retrieve information about each module when I display the hidden table row. The information is fetched from the page {modules/$moduleid}. While I understand how to utilize AJAX, my challenge l ...

Having trouble with Autocomplete not entering cities into the form?

While experimenting with Google's API, I have encountered confusion regarding why cities like Staten Island, Brooklyn, Queens, and various others are not being placed into the form like other cities. According to Google's API, "locality" is suppo ...

Exploring the 3D Carousel Effect with jQuery

After creating a 3D carousel using jQuery and CSS3, I am looking to enhance it with swiping support. While there are plenty of libraries available for detecting swipes, I specifically want the carousel to start rotating slowly when the user swipes slowly. ...

AngularJS is encountering a 415 error due to an unsupported media type

Spring code @RequestMapping(value="/users",method=RequestMethod.POST,headers = "content-type=application/json;application/x-www-form-urlencoded; charset=UTF-8") public @ResponseBody String createNewUser( @RequestBody @Valid User user) { System.out.pri ...

Modifying the structure of serialized data

After serializing a JS form, the data looks like this: .....&xx=xxx&otherError=&input=SMS&message=sdfgs&...... Can anyone provide guidance on how to replace the value of message with the content of a textarea before making an ajax cal ...

Incorporating Redux Object into Props in a React Functional Component: A Step-by-Step Guide

Looking for assistance with utilizing the "user" object from reduxReducer within a functional component. To access this object, I am currently using mapStateToProps in the following way: const mapStateToProps = (state) => ({ login: state.login, } ...

"Make your slides smooth and responsive with the unslick option in slick

Currently implementing the Slick Slider on a WordPress website. The slider is designed to display 3 columns at a screen size of 1024px and above. When the screen size drops below 1024px, the slider adjusts to show 2 columns, and on mobile devices, it swit ...

The process of incorporating unsigned right shift for BigInt in JavaScript

I attempted the implementation provided in this answer, but unfortunately, it seems to be ineffective. function urs32(n, amount) { const mask = (1 << (32 - amount)) - 1 return (n >> amount) & mask } function flip32(n) { const mask ...

PHP validation for email after Ajax form submission

Currently, I am in the process of creating an HTML contact form. To validate the form upon clicking the submit button, I have integrated the JavaScript code provided below: function leftValue(e, t, n) { $(this).text(t.parent()[0].style.left) } $(document) ...

Unable to locate module: Unable to locate the file './Header.module.scss' in '/vercel/path0/components/Header'

I encountered an error while attempting to deploy my next application on Vercel. I have thoroughly reviewed my imports, but I am unable to pinpoint the issue. Module not found: Can't resolve './Header.module.scss' in '/vercel/path0/comp ...