I'm beginner on AngularJs and I have a difficult to show the sum of two numbers. The first script work perfectly :
<div>
<p><input type="text" ng-model="price1" /> <strong>{{price1}}</strong></p>
<p><input type="text" ng-model="price2" /> <strong>{{price2}}</strong></p>
<p><strong>{{total = (price1 * 1 + price2 * 1) }}</strong></p>
</div>
But when I try to test this using a controller, like this :
<div ng-controller="myCtrl">
<p><input type="text" ng-model="price1" /> <strong>{{price1}}</strong></p>
<p><input type="text" ng-model="price2" /> <strong>{{price2}}</strong></p>
<p><strong>{{total}}</strong></p>
</div>
<script>
var app = angular.module('firstApp', []);
app.controller('myCtrl', ['$scope', function($scope) {
$scope.total = ($scope.price1 + $scope.price2);
}]);
</script>
I have no result, just a NaN value. I have no idea what happen !