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(''); } }); });
Comments
Post a Comment