Screening data entries

.js

"rpsCommonWord": [
    {
        "addressWeightPct": "60",
        "charSubstituteWeightPct": "15",
        "nameWeightPct": "40",
        "oIdNumber": "21",
        "shortWordMinLthWeightPct": "100",
        "substituteWeightPct": "5",        
        "wordName": "Word 3"
    },
    {
        "addressWeightPct": "60",
        "charSubstituteWeightPct": "15",
        "nameWeightPct": "40",
        "oIdNumber": "21",
        "shortWordMinLthWeightPct": "100",
        "substituteWeightPct": "5",        
        "wordName": "abc 3"
    },
    {
        "addressWeightPct": "60",
        "charSubstituteWeightPct": "15",
        "nameWeightPct": "50",
        "oIdNumber": "21",
        "shortWordMinLthWeightPct": "100",
        "substituteWeightPct": `enter code here`"5",        
        "wordName": "Wordefd 3"
    }
];

$scope.onClickGo = function() { 
     //
};

.html

<strong><font color="#660099" face="Arial" size="1">wordName : </font></strong>
<strong><font color="#660099" face="Arial" size="1"><input name="wordName" type="text" value=""></font></strong>
<strong><font color="#660099" face="Arial" size="1">nameWeightpct : </font></strong>
<strong><font color="#660099" face="Arial" size="1"><input name="nameWeightpct" type="text" value=""></font></strong>

In my current task, I am looking to filter records where the "wordName" is either "Word" or "WO" and the "nameWeightpct" is equal to 40. This needs to be done in the frontend without relying on backend services. The approach should be similar to a "Like%" query in MySQL but executed solely in the frontend by filtering an array of records that match or closely resemble the entered values.

Answer №1

To incorporate filter functionality in Angular, define two variables for capturing the search values of "wordName" and "nameWeightpct". Utilize the filter feature provided by Angular to achieve this.

Here's an example code snippet:

<div ng-init="friends = [{name:'John', phone:'555-1276'},
                     {name:'Mary', phone:'800-BIG-MARY'},
                     {name:'Mike', phone:'555-4321'},
                     {name:'Adam', phone:'555-5678'},
                     {name:'Julie', phone:'555-8765'},
                     {name:'Juliette', phone:'555-5678'}]"></div>

<label>Search Name: <input ng-model="searchName"></label>
<label>Search Phone: <input ng-model="searchPhone"></label>
<table id="searchTextResults">
  <tr><th>Name</th><th>Phone</th></tr>
  <tr ng-repeat="friend in friends | filter:searchName | filter: searchPhone">
   <td>{{friend.name}}</td>
   <td>{{friend.phone}}</td>
</tr>
</table>

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

Unable to invoke functions in the child window

In my Vue page, I have a script that opens a child window using the code snippet below: this.presentation = window.open( this.$router.resolve({name:'presentation'}).href, 'child window', 'width=auto,height=auto' ) ...

What is the best way to duplicate a tag that contains multiple other tags with attributes?

My form, named 'myForm', needs a div tag with the id 'original' to be added every time I click a button. Can someone help me figure out how to add these tags? The new tags should appear after the original one, but still within myForm. ...

Showing a collection of articles on a webpage using Nuxt/content - Step by step guide

I have implemented the nuxt/content module to establish a documentation website. In a recent post on the Nuxt blog, they demonstrated displaying content in a separate index.vue page and post details on the _slug.vue page. My goal is to present a list of ...

The absence of a backslash in the JSON string is noticed upon uploading it to the database

After using the JSON.stringify() method in JavaScript to convert my JSON object into a JSON string, I insert it into a database via AJAX posting to a PHP file. $("#saveToDatabase").click(function(){ var place = searchBox.getPlaces(); var locati ...

Modify a necessary input value using jQuery or JavaScript

I am looking to update the required value of an input based on a checkbox selection. Here is my current code, any assistance would be appreciated. <input type="checkbox" id="no_land_line" name="no_land_line" value=""> // check this box if no land li ...

Using Node.js to access the public stream of app.net for streaming purposes

Exploring the world of streaming and HTTP long living connections for the first time. This is where I'm at: const accessToken = require('./config.js').accessToken; const https = require('https'); const req = https.request({ ...

Is it possible for a component to have multiple templates that can be switched based on a parameter?

Scenario My task is to develop a component that fetches content from a database and displays it on the page. There needs to be two components working together to create a single page, following a specific component tree structure. DataList - receives ful ...

What is the best approach for testing a component that makes use of React.cloneElement?

My main component fetches children using react-router in the following manner: class MainComponent extends Component { render() { return ( <div> {React.cloneElement(children, this.props.data)} </div> ) } } I a ...

In the Swiper function of JavaScript within a Django template, the occurrence of duplicate elements (products) is being generated

Experimenting with displaying products in a Django template, I decided to utilize the Swiper js class. This allowed me to showcase the products within a div, complete with navigation buttons for scrolling horizontally. However, when testing this setup wit ...

AngularJs operates similarly to the way JQuery functions

Hello everyone, I am hoping to achieve a similar functionality in Angular like this: $('[property="something"]').remove(). Could anyone assist me with this? ...

Sharing and displaying images on Sails JS platform

Using Sails JS, I am attempting to upload an image and display it in a view. Queries: The uploaded image is located in .tmp/uploads, how can I retrieve it from a view? Is there a method to access the uploaded image? The image's name is altered in ...

AngularJS allows for the uploading of files in each row of a table

Currently, I have implemented a table where users can enter details in each row and view the corresponding image. This functionality has been achieved using AngularJS. Although I managed to get it working for the first row after much effort, I am now faced ...

The data shown in the C3.js tooltips

I have successfully created a chart like this on jsfiddle: http://jsfiddle.net/q8h39/111/ The chart includes customized tooltip contents for each plot. I attempted to add extra data to the tooltip using the "indexOf()" method, but unfortunately, it did no ...

"Cross-origin resource sharing problem while working with NodeJs, Express, and React on

Currently, I am working on a small project where I am using NodeJs and Express for the backend and React for the client side. In order to tackle CORS policy issues, I have implemented the "cors" npm package on the server side, but unfortunately, it doesn& ...

The Zip file generated in memory is experiencing corruption

I'm encountering an issue while attempting to serve a zip file generated in memory by Flask to a JavaScript front-end. However, the downloaded file appears corrupted and I am unsure of what mistake I may be making. @app.route('/route') def ...

The NPM Install process seems to be skipping certain files that were successfully installed in the past

When I first installed NPM Install in a folder, it created multiple folders and files: node_modules public src .DS_Store package.json package-lock.json webpack.config.js After that, npm start functioned perfectly. Now, as I embark on a new project for th ...

When hovering over the bootstrap dropdown, the main dropdown remains a clickable link

How can I create a bootstrap dropdown menu that activates on hover, while still allowing the main button to link to a different page when clicked? Below is the HTML code: <div class="body-wrap"> <div class="container"> <nav class="navbar n ...

Incorporating `ngRepeat` to populate options within a <select> element

Attaching data to each row and modifying it based on conditions I want to attach data to each individual row in Angular and also be able to modify that data depending on certain conditions. <select id="subject" name="subject" ng-mo ...

Unable to display shadows in Three.js

I've hit a roadblock with the shadow effect at the moment, despite trying various solutions for hours, it's still not appearing. Can anyone point out what I may have done incorrectly? Below is the code snippet for my current scene: //Setting up ...

How to Condense an Element Using Position: Absolute

https://i.sstatic.net/GMUss.png I'm attempting to create functionality where the "Open Chat" button displays an Absolute positioned div, then hides it when clicked again. I experimented with using the react-collapse component, but encountered issues ...