Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49526

Variable with number produces always 'is not a valid number'

$
0
0

@cjs1976 wrote:

Hi!

In my page I use variables from the controller of the page. For example:

<label class="item item-input item-stacked-label">
  <span class="input-label">Projekt Id:</span>
  <input type="number" placeholder="0" value="{{cpc.projektid}}" disabled>
</label>

The controller does some calculation over a factory, and get's also some data from an SQLite database. If I check the type of my variables in the controller or in the factory, i get for Example:

console.log(typeof cpcVm.projektid); => number
console.log(angular.isNumber(cpcVm.projektid)); 0> true

So for me, this means, that the value of the variable is a number!?

But I get always the warning "The specified value "{{cpc.projektid}}" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+.\d+|.\d+)([eE][-+]?\d+)?"

For the projektid this is not a big issue, but I have more complicated calculations, and I need also set some filters, which work only if the number is a number. For example:

I tried already to give an additonal parseFloat() in my controller and the factory, but there is no change. The controller and the factory say it's a number, but in the html it creates an error, and I can't use the filter.

Another strange thing: If I set the value of the variable in the factory or the controller manually (for example return 12;), than it works.

Any ideas?

Thanks,
Christian.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49526

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>