2016-07-12 45 views
1

我正在製作一個簡單的計算器Web應用程序,並認爲我會給AngularJS一個去。一切都在瀏覽器工作正常,火狐等AngularJS和Internet Explorer無法呈現我的AngularJS

但是我們仍然支持IE9不幸,我已經寫了角JS代碼是不能工作在IE9我只是得到{{變量}}

任何想法?

HTML代碼:

<head> 
    <title></title> 

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.29/angular.min.js"></script> 
    <script src="PumpCalculator.js"></script> 
</head> 

<body> 
    <div ng-app="MotorApp" ng-controller="MotorController"> 
     <h2>Pump Calculations</h2> 
     <p> 
      Outside Root Diameter: 
      <input ng-model="OutsideRoot">(mm)</p> 
     <p> 
      Inner root diameter: 
      <input ng-model="InnerRoot">(mm)</p> 
     <p> 
      Height: 
      <input ng-model="Height">(mm)</p> 
     <p>Displacement: {{ DisplacementCC()}}<b>cc</b> 
      <br/>{{ DisplacementCU() }} <b>cu in</b> 
     </p> 
     <br /> 
     <h2>Volume</h2> 
     <p>cc: 
      <input ng-model="VolumeCC"> 
     </p> 
     <p>Pump rpm: 
      <input ng-model="VolumePumpRPM"> 
     </p> 
     <p>{{ PumpLitres() }} <b>Litres/Min</b> 
      <br /> {{ GPM() }} <b>GPM</b> 
     </p> 
     <h2>Horse Power</h2> 
     <p>Flow: <input ng-model="FlowLitresMin"> (Litres/min) <input ng-model="FlowGPM"> (GPM)</p> 
     <p>Force In Pressure: <input ng-model="ForceBar"> (Bar) <input ng-model="ForcePSI"> (psi)</p> 
     <p>{{ ForceKW() }} <b>KW</b> <br /> {{ ForceHP() }} <b>HP</b></p> 
     <br /> 
     <h2>Power to drive a pump</h2> 
     <b>Known factors</b> 
     <p>Pressure = <input ng-model="PowerPressure"> <b>Bar</b></p> 
     <p>Pump displacement = <input ng-model="PowerPump"> <b>cm³/rev</b></p> 
     <p>Input speed = <input ng-model="PowerInput"> <b>rpm</b></p> 
     <p>Pump Efficiency = <input ng-model="PowerEff"> <b>%</b></p> 
     <br /> 
     <b>Results</b> 
     <p>Power = {{ PowerResult() }} <b>Kw</b></p> 
     <p>Flow = {{ FlowResult() }} <b>L/min</b></p> 
    </div> 
</body> 

</html> 

AngularJS代碼:

angular.module('MotorApp', []).controller('MotorController', function($scope) { 
    //Pump Calculations 
    $scope.OutsideRoot = 0; 
    $scope.InnerRoot = 0; 
    $scope.Height = 0; 
    $scope.DisplacementCC = function() { 
     var outside = $scope.OutsideRoot; 
     var inner = $scope.InnerRoot; 
     var height = $scope.Height; 
     var a = ((((outside * outside * 0.7854) - (inner * inner * 0.7854)) * height)/1000).toFixed(4) 
     return a; 
    } 
    $scope.DisplacementCU = function() { 
     var outside = $scope.OutsideRoot; 
     var inner = $scope.InnerRoot; 
     var height = $scope.Height; 
     var b = ($scope.DisplacementCC() * 0.06102).toFixed(4); 
     return b 
    } 
    //Volume Calculations 
    $scope.VolumeCC = 100; 
    $scope.VolumePumpRPM = 10; 
    $scope.PumpLitres = function() { 
     var vol = $scope.VolumeCC; 
     var rpm = $scope.VolumePumpRPM; 
     return ((vol * rpm)/1000).toFixed(4); 
    } 
    $scope.GPM = function() { 
     var vol = $scope.VolumeCC; 
     var rpm = $scope.VolumePumpRPM; 
     return ($scope.PumpLitres()/3.7854).toFixed(4); 
    } 
    //Horse Power Calculations 
    $scope.FlowLitresMin = 0; 
    $scope.FlowGPM = 0; 
    $scope.ForceBar = 0; 
    $scope.ForcePSI = 0; 
    $scope.ForceKW = function() { 
     var flowL = $scope.FlowLitresMin; 
     var forceB = $scope.ForceBar; 
     return ((flowL * forceB)/600).toFixed(4); 
    } 
    $scope.ForceHP = function() { 
     var flowG = $scope.FlowGPM; 
     var forceP = $scope.ForcePSI; 
     return ((flowG*forceP)/1714).toFixed(4); 
    } 
    //Power To drive a pump 
    $scope.PowerPressure = 0.00; 
    $scope.PowerPump = 0.00; 
    $scope.PowerInput = 0.00; 
    $scope.PowerEff = 92.00; 
    $scope.PowerResult = function() { 
     return (($scope.PowerPressure*($scope.PowerPump*$scope.PowerInput))/(600000*($scope.PowerEff/100))).toFixed(2); 
    } 
    $scope.FlowResult = function() { 
     return (($scope.PowerInput/1000)*($scope.PowerPump*($scope.PowerEff/100))).toFixed(2); 
    } 
}); 
+0

看到這個:http:// stack overflow.com/questions/26567729/angular-js-not-working-with-ie9-but-works-with-other-browsers – Adrian

+0

你可能會遇到一些javascript問題。因此,IE無法初始化應用程序 –

+0

不幸的@阿德里安我試圖在ng - **之前添加「數據」,但它仍然只顯示{{variable}} – Adam91Holt

回答

-1

我解決了,這是要添加的方式...

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 

爲標籤一號線

相關問題