Ejemplo ng-click

by logongas

HTML

<body ng-app="MiApp" ng-controller="MiPageController">
    A:<input type="number" ng-model="a"><br />
    B:<input type="number" ng-model="b"><br />
    <button ng-click="sumar()">Sumar</button><br />
    Resultado:<input type="number" ng-model="resultado"><br />        
</body>

JavaScript

var app = angular.module("MiApp", []);

function MiPageController($scope) {
    $scope.a=3;
    $scope.b=7;
    $scope.resultado=0;
    $scope.sumar=function() {
      $scope.resultado=$scope.a+$scope.b;
    }
}