angular.js - 用ionic,angularjs做一个计算器,总是不能显示计算结果?
阿神
阿神 2017-05-15 16:57:40
[AngularJS讨论组]

index.html:




  
  
  

  
  

  

  
  

  
  

  
  
  





  
    

个人所得税计算器

个人所得税:

个人收入:

收入金额:


计算结果

应缴税款:

税后收入:

calculatorCtrl.js:

angular.module('calculator.controllers', [])
  .controller("calculatorCtrl", function ($scope) {

    $scope.cal = function () {
      var left = $scope.shouru - 3500;
      if (left <= 1500) {
        yingjiao = left * 0.03;
      }
      else if (left <= 4500) {
        yingjiao = left * 0.1 - 105;
      }
      else if (left <= 9000) {
        yingjiao = left * 0.2 - 555;
      }
      else if (left <= 35000) {
        yingjiao = left * 0.25 - 1005;
      }
      else if (left <= 55000) {
        yingjiao = left * 0.3 - 2755;
      }
      else if (left <= 80000) {
        yingjiao = left * 0.35 - 5505;
      }
      else(left > 80000)
      {
        yingjiao = left * 0.45 - 13505;
      }
      $scope.shuihou = $scope.shouru - yingjiao;
    };
  })

app.js:

angular.module('calculator', ['ionic','calculator.controllers'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})
阿神
阿神

闭关修行中......

全部回复(1)
给我你的怀抱

Ng-app 和Ng-controller 不要放在一个元素上,另外你的问题是什么。用ionic start [project_name] blank 创建项目,然后在那个基础上改就好啦

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号