angularjs - print hr depending on ng-model value -


i have input type number follows:

<input type="number" ng-model="question.numberoflines" min="1" max="5" /> 

this stored inside object on scope:

$scope.question = {        questiontext: "",        size: "",        alignment: "",        color: "",        numberoflines: "",        htmllines: "" } 

how can make when numberoflines changes of value (1,2,3,4, etc) htmllines gets same number of <hr /> value? i'm having trouble trying figure out. appreciated

you'll need create array has length equal input in order use ngrepeat directive take care of hr's:

var app = angular.module('plunker', []);  app.controller('mainctrl', function($scope) {   $scope.question = {        questiontext: "",        size: "",        alignment: "",        color: "",        numberoflines: "",        htmllines: ""   };   $scope.hrarray = [];   $scope.$watch('question.numberoflines', function(n, o) {     $scope.hrarray = [];     (var i=0; i<n; i++) {       $scope.hrarray.push('');     }   }); }); 

plunkr here


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -