How can I take a boolean from the Model in my cshtml file and pass it to the javascript constructor to be used during the running of the javascript? The code I have currently shows the variable as "undefined" when debugging.
So, in cardScanner.cshtml I have a model with the bool OcrEnabled, so I am trying to pass @Model.OcrEnabled to the javascript constructor by doing this:
window.dls = new CardScanner("#license", @Model.OcrEnabled.ToString().ToLower());
Then, in the javascript file scanner.js I have the constructor,
CardScanner = function (scope, ocrEnabled) {
this.scope = $(scope);
this.ocrEnabled == ocrEnabled;
};
and then the function where I am trying to use the variable
if (this.ocrEnabled == false)
At this moment in the debugger "this.ocrEnabled" reads undefined.