title: AngularJS: controller's function
body: <p>I have a problem using AngularJS in my application. Particularly, when I have to call a function that I have Written in controller part, it doesn't work.
  Anyone knows how I have to proceed. Thanks.</p>
  
  <p>This is my code... the function that gives me some problems is called totale().</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('pizza', []);
  
  
  app.controller('a1', function ($scope) {
      
      
      $scope.listino = [
           {id: 1, nom: 'Marinara', prezzo: 3.00},
           {id: 2, nom: 'Margherita', prezzo: 4.50},
           {id: 3, nom: '4 Formaggi', prezzo: 6.50},
           {id: 4, nom: 'Carbonara', prezzo: 6.00},
           {id: 5, nom: 'Boscaiola', prezzo: 7.00},
           {id: 6, nom: 'Patatosa', prezzo: 5.50},
           {id: 7, nom: 'Capricciosa', prezzo: 6.00},
      ];
  
        
      $scope.paste = [
          {n: 1, nome: 'Tradizionale'},
          {n: 2, nome: 'Integrale'}
      ];
  
      $scope.basi = [
          {n: 1, nome: 'Pomodoro', prezzo: 1.50},
          {n: 2, nome: 'Bianca',  prezzo: 0}
      ];
  
      $scope.ingredienti = [
          {n: 1, nome: 'Verdure', prezzo: 1.50, select: false},
          {n: 2, nome: 'Affettati',  prezzo: 1.85, select: false},
          {n: 3, nome: 'Funghi',    prezzo: 2.90, select: false},
          {n: 4, nome: 'Altri',  prezzo: 2, select: false}
      ];
      
      $scope.totale= function(){
          
          var tot=0;
          var sel = false;
  
          if ($scope.listino.val) {
              tot+=parseFloat($scope.listino.val);
          }
  
          if ($scope.basi.b) {
              tot+=parseFloat($scope.basi.b);
          }
  
          angular.forEach($scope.ingredienti, function (ingrediente) {
              if (ingrediente.selected) {
                  tot += ingrediente.prezzo;
                  sel = true;
              }
          });
  
          $scope.isDisabled = ($scope.paste.p || $scope.listino.val || $scope.basi.b || sel) ? false : true;
  
          return tot;
      };
      });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"&gt;&lt;/script&gt;
  &lt;button ng-click="$scope.ordine()" type="button" class="bottone btn btn-danger" ng-disabled="$scope.isDisabled"&gt;
                               Totale da pagare {{$scope.totale()}}€&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>