代码之家  ›  专栏  ›  技术社区  ›  David Klempfner

非空的ng app name停止计算表达式

  •  0
  • David Klempfner  · 技术社区  · 5 年前

    为什么 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>
    
    0 回复  |  直到 5 年前