Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/02/2015, 10:30
Eclypse05
 
Fecha de Ingreso: julio-2012
Mensajes: 11
Antigüedad: 11 años, 9 meses
Puntos: 0
Problema con un simple código de AngularJs!

Mi problema es que ando iniciándome con este nuevo framework que todos mencionan que es muy bueno y ayer lo estuve practicando y he tenido un problema para aumentar el numero de una variable "amount".

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html lang="es" ng-app="miApp">
  3.    <meta charset="UTF-8">
  4.    <title>Document</title>
  5.    <link rel="stylesheet" href="bootstrap.min.css">
  6.    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
  7.    <script type="text/javascript" src="angular.js"></script>
  8. </head>
  9. <body ng-controller="miControlador">
  10.    <h1>{{phrase}}</h1>
  11.    {{expense.description}} - {{expense.amount}}
  12.    <button ng-click="increaseAmount">Increase amount</button>
  13. </body>
  14. </html>

Código Javascript:
Ver original
  1. var app = angular.module('miApp', [])
  2.  
  3.    app.controller('miControlador', ['$scope', function ($scope) {
  4.       $scope.expense = {
  5.          description: 'food',
  6.          amount: 10
  7.       };
  8.  
  9.       $scope.phrase = 'the sky is blue';
  10.  
  11.    $scope.increaseAmount = function() {
  12.       $scope.expense.amount ++;
  13.       }
  14.    }]);