简体   繁体   中英

Angular code shows in page

I'm in the process of learning angular. When I execute the code below

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example - example-guide-concepts-1-production</title>


  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.0/angular.min.js"></script>



</head>
<body >
      <div ng-app ng-init="qty=1;cost=2">
      <b>Invoice:</b>
      <div>
        Quantity: <input type="number" min="0" ng-model="qty">
      </div>
      <div>
        Costs: <input type="number" min="0" ng-model="cost">
      </div>
      <div>
        <b>Total:</b> {{qty * cost | currency}}
      </div>
    </div>
</body>
</html>

The code that renders shows {{qty * cost | currency}}. Is angular not loading into the browser (chrome) ? I've checked the version of angular and it appears to be ok. Thanks.

Most probably you angular js is not loaded properly.

Check this plunker with your code, this works.

<!DOCTYPE html>
<html>

  <head>
    <script data-require="angular.js@*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body>
    <div ng-app ng-init="qty=1;cost=2">
        <b>Invoice:</b>
        <div>
            Quantity:
            <input type="number" min="0" ng-model="qty">
        </div>
        <div>
            Costs:
            <input type="number" min="0" ng-model="cost">
        </div>
        <div>
            <b>Total:</b> {{qty * cost | currency}}
        </div>
    </div>
</body>

</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM