Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jpeterson579's avatar

Call to undefined function - Laravel5 and AngularJS issue

I am getting the following error which is very strange to me. Please help! Ah

Call to undefined function total()

Blade:

<div ng-app="myApp">
    <div ng-controller="CTRL30">
        <input type="text" ng-model="val_1" />
        <input type="text" ng-model="val_2" />
        <input type="text" value="total()" />
        <p>{{ 'Angular wors!' }}</p>
    </div>
</div>
<script type="text/javascript">
    function CTRL30 ($scope) {
        $scope.val_1 = '4';
        $scope.val_2 = '3';
        $scope.total = function() {return Number($scope.val_1) + Number($scope.val_2);};
    }
</script>

FYI <input type="text" value={ { "total() "} } /> looks like this. Curly brackets not showing up here for some reason

0 likes
1 reply
Penderis's avatar

Never worked in angular but I think when you do ng-model="val_1" it makes it into a function that is callable thus you can do $scope.val_1 now you have that for both val_1 and val_2 , not total , so no binding for total it does not know what to , you might need something similar to a computed property to assign total.

Please or to participate in this conversation.