如何让AngularJS在模板中执行计算?

时间:2016-07-16 11:15:51

标签: angularjs

下面的脚本不执行计算{{ 5+ 15 }},它只返回“{5}”中的“5+ 15”

HTML:

  <html>
    <head>

  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  <title></title>
  <script src="lib/ionic/js/angular/angular-animate.js"></script>
  <script src="lib/ionic/js/angular/angular-sanitize.js"></script>
  <script src="lib/ionic/js/angular/angular-resource.min.js"></script>
  <script src="lib/ionic/js/angular/angular.js"></script>
  <script src="lib/ionic/js/angular/angular.min.js"></script>
  <link href="lib/ionic/css/ionic.css" rel="stylesheet">
  <link href="css/style.css" rel="stylesheet">  
  <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
  <script src="js/app.js"></script>
</head>
<body ng-app="starter">
  <ion-pane>
    <ion-header-bar class="bar-stable">
      <h1 class="title">
        <div style="color:#FF00FF" align="center">Ionic Testing</div>
      </h1>
    </ion-header-bar>
    <ion-content>
      <div ng-app="FirstModule" ng-controller="myFirstControl">
        <input type="text" ng-model="FirstName" name="FirstName">
        <input type="text" ng-model="SecondName">
        <span ng-bind="FirstName"></span> Full Name: {{ 5+ 15 }}
      </div>
    </ion-content>
  </ion-pane>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

我刚刚编辑了你的问题并注意到你有两次ng-app声明:

<body>标记中有一个,<div>内的第一个<ion-content>上有另一个。

删除其中一个(无关紧要),您的计算应该按预期工作。