首页 > 解决方案 > 非空白 ng-app 名称停止表达式被评估

问题描述

为什么会ng-app="myApp"导致表达式不计算?

如果我使用ng-app="",它工作正常:

<!DOCTYPE html>
<html>
<head>

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

<div ng-app="" ng-init="quantity=2;price=5">

<h2>Cost Calculator</h2>

Quantity: <input type="number" ng-model="quantity">
Price: <input type="number" ng-model="price">

<p><b>Total in dollar:</b> {{quantity * price}}</p>

</div>

</body>
</html>

标签: angularjs

解决方案


推荐阅读