javascript - 函数完全打印

标签 javascript angularjs

对 AngularJs 非常陌生,并试图找出为什么我的函数完全打印如下。

Hello function () { return (this.sal) * 12; }

这是我的代码。

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
    <script type="text/javascript">
    var app=angular.module("sample",[]);
    app.controller("emp",function($scope){
      $scope.Name="Jag";
      $scope.sal="4500"
      $scope.getAnnualSal = function()
      {
         return (this.sal) * 12;
      }
    });
    </script>
  </head>
  <body ng-app="sample">
<div ng-controller="emp">
  Hello {{getAnnualSal}}
</div>
  </body>
</html>

最佳答案

试试这个,它是一个函数而不是变量:

Hello {{getAnnualSal()}}

关于javascript - 函数完全打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45863354/

相关文章:

java - 如何在客户端从 JavaScript 执行 Java 文件

javascript - 如何在 ionic/cordova/phonegap 中检查在前台或后台运行的应用程序

c# - 如何关闭服务器端按钮单击中的当前选项卡?

javascript - 在 angularjs 中渲染 &lt;script&gt; 标签

javascript - Angularjs 选项卡仅适用于使用 ng-repeat 的唯一数组元素

angularjs - 为什么当 html 包含 div 时使用 ng-repeat 迭代 html 会失败?

javascript - jsp : Could I change the order of render/execution

javascript - 下载文件时在文件内容中获取类型 [object object],而不是使用 angular 7 的 blob

angularjs - 为什么我会在指令定义中收到错误 TS2345?

javascript - AngularJS 后处理链接