15408

using ionic range to set months and years

Question:

I am using a ionic range in my html page to set the number of months.It looks like this

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/Fxv11.jpg" data-original="https://i.stack.imgur.com/Fxv11.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

I want this to display as years and months when i slide the ionic range. Ex: first months goes upto 12 and automatically becomes a year.How can i acheive this?

My html code for ionic range

<label class="labelCalhead"> Select your Loan Term :</label>

<div class="item range"> <input type="range" name="volume" min="1" max="30" ng-model="loanTerm" ></div> <label class="labelCal">Monthly</label>

<input type="text" decimal-places ng-model="loanTerm" onkeypress='return event.charCode >= 48 && event.charCode <= 57 || event.charCode == 46' min="0" max="30" STYLE="color: #72A4D2; " />

<br>

To be Precise i want to do something like this

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/WHqch.jpg" data-original="https://i.stack.imgur.com/WHqch.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

I'll give you simplest code to show you how to do it, you can then add textboxes as in the UI above.

In the controller define following function and also init the initial value for the slider

$scope.drag = function(value) { $scope.years = Math.floor(value / 12); $scope.months = value % 12; }; $scope.rangeValue = 0;

Then in your template

<input type="range" name="volume" min="0" max="100" ng-model="rangeValue" ng-change="drag(rangeValue)"> <div>Total: {{rangeValue}} Years: {{years}} Months: {{months}}</div>

Now when you drag the range input it will show the years and months.

Recommend

  • Django admin with many to many choices
  • Entity Relationships - Can a weak entity take part in a 'one to many' relationship as the
  • Invalid argument supplied for foreach() .. Wordpress
  • Cassandra: What is a subcolumn
  • How can I count unique terms in a plaintext file case-insensitively?
  • Recording values of radio buttons in ember
  • Activation Function choice for Neural network
  • Image map in Flex
  • How to getText() from the input field of an angularjs Application
  • xcode don't localize specific strings
  • Combining two different ActiveRecord collections into one
  • Angularjs pass function from Controller to Directive (or call controller function from directive) -
  • Django invalid literal for int() with base 10
  • Eloquent update method change created_at timestamp
  • Swift: Switch statement fallthrough behavior
  • Allowing both email and username for authentication
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • FileReader+canvas image loading problem
  • Insert into database using onclick function
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Deselecting radio buttons while keeping the View Model in synch
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Can Jackson SerializationFeature be overridden per field or class?
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • Matrix multiplication with MKL
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How do you join a server to an Active Directory (domain)?
  • Java static initializers and reflection
  • How does Linux kernel interrupt the application?
  • unknown Exception android
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app
  • How to push additional view controllers onto NavigationController but keep the TabBar?