M
M
medianoche2015-04-15 02:15:47
JavaScript
medianoche, 2015-04-15 02:15:47

How to update a directive in JS file in AngularJS?

I have this html page:

<input type="number" placeholder="Длина" ng-model="length">
<a ng-click="start()">Рассчитать</a>
Расчет: {{length}}

With the help of such a code, 2, 4, 8, 16, etc. appear at the place of calculation.
$scope.length = 2;
$scope.start = function() {
  $scope.length =  $scope.length * 2;
};

But if you manually enter the Length into the corresponding input and click "Calculate", then nothing happens. I suspect you need to do something with apply and watch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TekVanDo, 2015-04-15
@medianoche

Everything works.. jsbin.com/luyigarizo/1/edit?html,js,output

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question