Código HTML :
<!DOCTYPE html> <html lang="es" ng-app="miApp"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="bootstrap.min.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script> <script type="text/javascript" src="angular.js"></script> </head> <body ng-controller="miControlador"> <h1>{{phrase}}</h1> {{expense.description}} - {{expense.amount}} <button ng-click="increaseAmount">Increase amount</button> </body> </html>
Código Javascript :
var app = angular.module('miApp', []) app.controller('miControlador', ['$scope', function ($scope) { $scope.expense = { description: 'food', amount: 10 }; $scope.phrase = 'the sky is blue'; $scope.increaseAmount = function() { $scope.expense.amount ++; } }]);