I'm trying to make stimulus controller to mask 2 input field, "gross revenue" and "operating cost" to display thousand separator on both fields. I've tried imaskjs with stimulusjs, but I don't know why it doesn't werk at all.
<div class='' data-controller="currency">
    <%= f.label :gross_revenue %>
    <%= f.number_field :gross_revenue, class: '', data: { currency_target: "gross" } %>
  </div>
Below is my controller
import { Controller } from "@hotwired/stimulus"
import IMask from "imask"
// data-controller="currency"
export default class extends Controller {
  static targets = [ "currency" ]
  connect() {
    this.mask = IMask(this.currencyTarget, { 
      mask: Number,
      thousandsSeparator: ',',
    });
  }
  disconnect() {
    this.mask?.destroy();
  }
}
 
                        
You can't use
numberfield:https://imask.js.org/guide.html
Fix target name (you should rename it to something more generic as well):
You can also use just the controller element: