combine string inputs when ng-click is triggered

Is there a way to pass a concatenated string using ng-click to MyFunction(param: string)?

I have tried but so far, no luck:

<input id="MeasurementValue_{{sample.Number}}_{{$index}}" 
      ng-click="Vm.MyFunction('MeasurementValue_{{sample.Number}}_{{$index}}')"/>

Unfortunately, this method is not functioning as expected...

Answer №1

Have you given this a shot?:

  <input id="MeasurementValue_{{sample.Number}}_{{$index}}"
   ng-click="Vm.MyFunction('MeasurementValue' + '_' + {{sample.Number}} + '_' + {{$index}})"
   />

ng-click="Feel free to write your own JavaScript code here"

Answer №2

This solution appears to be effective.

<input id="MeasurementValue_{{sample.Number}}_{{$index}}" 
      ng-click="Vm.MyFunction('MeasurementValue_' + sample.Number + '_' + $index)"/>

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 "ng-click" functionality to HTML using ngSanitize

Currently tackling localization with Angular and hitting a roadblock with one final obstacle. Here's the json blob I'm working with: { "key": "_need_to_login_", "value": "You need to <a ng-click=\"login()\">log in< ...

On which platform is the getFeatureInfo request constructed using Cesium?

Currently, I am working with Cesium and Angular. I am trying to locate where the request URL is generated for GetFeatureInfo in Cesium, but unfortunately I am unable to find it. My goal is to display feature information when clicking on the map. However, ...

Creating a personalized NPM package: Converting and exporting TypeScript definitions

Question: Do I need to adjust my TS configuration or add a TS build step? I recently developed a new npm package: Custom-NPM-Package / - src -- index.js -- index.d.ts -- IType.ts accompanied by this tsconfig.json: { "compilerOptions" ...

Error: UserService (?) is missing parameters and cannot be resolved

Upon compiling my application, an error is appearing in the console: Uncaught Error: Can't resolve all parameters for UserService (?) Despite having @Injectable() present for the UserService, I am unsure where to troubleshoot further. import {Inj ...

The Angular Compiler was identified, however it turned out to be an incorrect class instance

Although this question has been asked before, I have exhausted all possible solutions that were suggested. Unfortunately, I still cannot resolve it on my own. Any assistance would be greatly appreciated. Error: ERROR in ./src/main.ts Module build failed: ...

Timing of Bindings in AngularJS

In my setup, I have a controller that calls a service to retrieve a list of categories: $scope.enquiryCategories = CategoryServices.listCategories(); The service then fetches this data from an external API: listCategories: function () { return $http({ ...

Challenges encountered while configuring data in the UI-grid

I'm having difficulty setting up UI-grid properly and presenting data in a specific format. My data structure looks something like this: var arr = [ {'name': 'a', age: '1'}, {'name': 'b&ap ...

Using Typescript to create an asynchronous function without explicitly declaring a Promise

When you examine TypeScript's async function, you may notice the redundancy with "async" and "Promise<type>". public async test(): Promise<string> { return "Test"; } Is there a way to configure TypeScript to handle async types ...

What is the correct way to use forwardRef in a dynamic import in Next.js?

I've been trying to incorporate the forwardRef in my code, but I'm facing some difficulties. Can anyone help me out with this? I'm encountering the following errors: Property 'forwardedRef' does not exist on type '{}'. ...

The reset function for the selector is failing to properly reset the data within the table

I need help with a selector that has multiple options and a reset button. When the reset button is clicked, it should reset the selector back to the first option. Although the selector resets as expected when the button is clicked, the data in the table r ...

What is the best way to use an Observable to interrogate a fork/join operation?

I have a forkjoin set up to check for the presence of a person in two different data stores. If the person is not found in either store, I want to perform a delete action which should return true if successful, and false otherwise. However, my current impl ...

Simple steps to turn off error highlighting for TypeScript code in Visual Studio Code

Hey there! I've encountered an issue with vscode where it highlights valid code in red when using the union operator '??' or optional chaining '?.'. The code still builds without errors, but vscode displays a hover error message st ...

Why do we often encounter a "SyntaxError: Unexpected token ;" error when a seemingly normal semicolon is present in distribution files?

Currently, I am in the process of developing a newsletter subscription API using node.js and typescript. This project involves my first experience with typeorm and PostgreSQL. Following several tutorials, I configured typeorm and created the entity types a ...

Examining AngularJS Jasmine Promises in IsolationDive into the world

Seeking help for testing a mocked Service with chained promises. Factory for Testing app.factory('factory', [ 'service', function( service ){ var baz; return { updateMe: function( updateObj ){ // do stuff with upd ...

Using the directive in AngularJS and passing ng-model as an argument

Currently, I am creating a custom directive using AngularJs, and my goal is to pass the ng-model as an argument. <div class="col-md-7"><time-picker></time-picker></div> The directive code looks like this: app.directive(' ...

What are the steps to customizing the button bar in the uib-datepicker-popup?

I want to customize the button bar for uib-datepicker-popup. Currently, it is using .btn-info, .btn-danger, and .btn-success for the 'today', 'clear', and 'close' buttons. Is there a way to easily change these to different but ...

ngInfiniteScroll Activates on Every Scroll Occurrence

Implementing ngInfiniteScroll for endless scrolling on my website has required me to set the height of the outer div to a specific value. Without this adjustment, the Infinite Scroll feature activates unintentionally. <div style="height: 1px"> &l ...

Is the TypeScript compiler neglecting the tsconfig.json file?

I am new to TypeScript and currently exploring how to set it up in WebStorm. One of the first steps I took was creating a tsconfig.json file in the main directory of my project and updating the built-in TypeScript compiler to version 1.6.2. However, despit ...

Exploring AngularJS: Leveraging the $resource.query method with a parameters object

Currently learning angular.js, trying to understand some of the less documented aspects. Let's consider this scenario - there's a server with a search method that accepts query parameters and returns search results, accessible through the GET /s ...

unable to call a function within Angular

To create a dynamic menu, I am utilizing primeng's menu panel. Firstly, I declare my item variable: items: MenuItem[]=[]; I have two JavaScript objects to incorporate into the menu, namely groupsItem and ejsItem. Here is their structure: groupsI ...