I am new in the world of angularjs, I need to enter only numbers from 1 to 10 in an input of type number. without using the min and max properties of HTML5
I found an example in Jquery, could you please help me to convert it into an angularjs directive, with its respective parameters that is:
<input type = "number" directive-range = "1,10">
The example I found in Jquery is the following. the example in jquery works without the min and max properties of html5 and is what I need:
<input type = "number" value = "1" min = "1" max = "10">
<p style = "display: none"> Accepting Only values 1-10 </ p>
var t = false
$ ('input'). focus (function () {
var $ this = $ (this)
t = setInterval (
function () {
if (($ this.val () <1 || $ this.val ()> 10) && $ this.val (). length! = 0) {
if ($ this.val () <1) {
$ this.val (1)
}
if ($ this.val ()> 10) {
$ this.val (10)
}
$ ('p'). fadeIn (1000, function () {
$ (this) .fadeOut (500)
})
}
}, fifty)
})
$ ('input'). blur (function () {
if (t! = false) {
window.clearInterval (t)
t = false;
}
})
I hope you can help me I do not understand much about angularjs directives
directive-limitor theminandmaxvalues?