Html 基于角度的应用程序的java脚本到类型脚本转换

Html 基于角度的应用程序的java脚本到类型脚本转换,html,typescript,Html,Typescript,上面的代码是卡路里计数器代码,并在图像文件中附加以下错误 没有错误,但当bmi.component.ts文件存在于表单中时,代码不会运行 我是这个平台的新手,做了大量的研究,但没有弄清楚 import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-bmi', templateUrl: './bmi.component.html', styleUrls: ['./bmi.comp

上面的代码是卡路里计数器代码,并在图像文件中附加以下错误

没有错误,但当bmi.component.ts文件存在于表单中时,代码不会运行 我是这个平台的新手,做了大量的研究,但没有弄清楚

    import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-bmi',
  templateUrl: './bmi.component.html',
  styleUrls: ['./bmi.component.css']
})
export class BmiComponent implements OnInit {

  static module(arg0: any, arg1: any): any {
    throw new Error("Method not implemented.");
  }
  constructor() { }

  ngOnInit() {
  }


}


'use strict';

var app = BmiComponent.module('app',  []);

app.controller('mainController', function($scope  :any ){
  //dropdown container
  $scope.activities = [
    {name: 'Little to no exercise', multiply: 1.2},
    {name: 'Light exercise (1–3 days per week)', multiply: 1.375}, 
    {name: 'Moderate exercise (3–5 days per week)', multiply: 1.55},
    {name: 'Heavy exercise (6–7 days per week)', multiply: 1.725},
    {name: 'Very heavy exercise (twice per day, extra heavy workouts)', multiply: 1.9}
  ];
  //dropdown container
  $scope.goals = [
    {name: 'Lose weight - 1lb per week', alt: 'tone', cals: 500}, 
    {name: 'Lose weight - 2lb per week', alt: 'tone', cals: 1000},
    {name: 'Gain weight - 1lb per week', alt: 'bulk', cals: -500},
    {name: 'Gain weight - 2lb per week', alt: 'bulk',cals: -1000},
    {name: 'Maintain weight', alt: 'tone', cals: 0}
  ];
  //function to get total BMR
  $scope.bmr = function() {
    let standard = (parseInt($scope.weight, 10) * 10) +
          (parseInt($scope.height) * 6.25) - 
          (parseInt($scope.age) * 5); //both genders only differ on the last addition or subtraction

      if($scope.gender === 'male'){
        return  standard + 5
      } else if ($scope.gender === 'female'){
        return standard - 161
      } else {
        return //break out and angular number validation will take care of NaN 
      }
    };
  //function to get total dailys cals
  $scope.cals = function() {
    if(Number($scope.bmr) !== NaN && $scope.selectedActivity != null && $scope.selectedGoal != null){
    return $scope.bmr() * Number($scope.selectedActivity.multiply) - Number($scope.selectedGoal.cals)
    } else {
      return
      };
  };
  //of daily cals how much should be protein
  $scope.proteinCals = function(){
   return  $scope.cals() * .55
  };
  //as above for carbs
  $scope.carbsCals = function(){
    return $scope.cals() * .25
  };
  //as above for fat
  $scope.fatCals = function(){ 
    return $scope.cals() * .2
  };

  //for each meal type, what % of the above should each contain
  $scope.breakfast = [
    {name: 'protein', value: function(){return $scope.proteinCals() * 0.0252 / 4}}, 
    {name: 'carbs', value: function(){return $scope.carbsCals() * .0933 / 4}},
    {name: 'fat', value: function(){return $scope.fatCals() * 0.3467 / 8}}
  ]; 
  $scope.snack = [
    {name: 'protein', value: function(){return $scope.proteinCals() * 0.0573 / 4}}, 
    {name: 'carbs', value: function(){return $scope.carbsCals() * .1295 / 4}},
    {name: 'fat', value: function(){return $scope.fatCals() * 0.04 / 8}}
  ]; 
  $scope.mainMeal = [
    {name: 'protein', value: function(){return $scope.proteinCals() * 0.4014 / 4}}, 
    {name: 'carbs', value: function(){return $scope.carbsCals() * .2591 / 4}},
    {name: 'fat', value: function(){return $scope.fatCals() * 0.2666 / 8}}
  ]; 
  //end of meal section

});

看见回答问题并提供答案,告诉我们你想做什么,你尝试了什么,得到了什么结果。错误信息尤其应该以文本形式出现在问题正文中。@jdv你能帮我吗?吸引好答案的最好方法是确保你的问题告诉我们你在做什么以及包括错误信息在内的确切问题。错误消息是什么?告诉我们你已经尝试了什么。基本上,您要求我们调试您的代码,而这不会给您带来太多的吸引力。到目前为止,您自己是如何调试的?在问题的文本中尽可能多地告诉我们这一点。