How to parseInt in Angular.js

前端 未结 7 1680
生来不讨喜
生来不讨喜 2020-11-28 13:07

Probably, it is the simplest thing but I couldn\'t parse a string to Int in angular..

What I am trying to do:



        
7条回答
  •  佛祖请我去吃肉
    2020-11-28 14:06

    var app = angular.module('myApp', [])
    
    app.controller('MainCtrl', ['$scope', function($scope){
       $scope.num1 = 1;
       $scope.num2 = 1;
       $scope.total = parseInt($scope.num1 + $scope.num2);
    
    }]);
    

    Demo: parseInt with AngularJS

提交回复
热议问题