Add the value between two Angular input

  <input type="number" ng-model="" ng-keyup="">

  <input type="number" ng-model="vm.honorarium" ng-keyup="">

<h1>{{ vm.sum }}</h1>

The function: = function(){
    this.sum = capital + honorarium;

I need to make the sum between capital and honorarium. But my solution does not work, maybe I have some problem in logic.

asked by Matias Cazas 09.02.2018 в 15:48

1 answer


If it's the only thing you need, you can use it in the following way

        <input type="number" ng-model="capital">

        <input type="number" ng-model="honorarium">

    <h1>{{capital + honorarium }}</h1>

You do not need to use any ng-X function to do this process, remember that these variables are kept in the $ scope, who is in charge of updating the information of them immediately ..

what you do inside the h1 is only add what is contained in your ng-model ..

answered by 09.02.2018 / 17:51