0

I have what I think is a pretty basic Angular JS question. Can someone please explain to me why the expression.

{{hi}}

Is not evaluating and I am getting the following error:

Uncaught TypeError: angular.module is not a function

Here's the plunker and the code is below.

Html:

<!DOCTYPE html>
<html>

  <head>
    <script src="https://code.angularjs.org/2.0.0-alpha.20/angular2.sfx.dev.js"></script>
    <script src="app.js"></script>
  </head>

  <body ng-app="expressionExample">

    <div ng-controller="ExampleController" class="expressions">
    {{hi}}
</div>

    <cmp></cmp>
  </body>

</html>

js:

angular.module('expressionExample', [])
.controller('ExampleController', ['$scope', function($scope) {
  var exprs = $scope.exprs = [];
  $scope.expr = '3*10|currency';
  $scope.hi= 'hi';
  $scope.addExp = function(expr) {
    exprs.push(expr);
  };

  $scope.removeExp = function(index) {
    exprs.splice(index, 1);
  };
}]);
4

2 に答える 2

0

Angular 2.0 リファレンスを使用しています

参照を 1.4.0-rc1 に更新したら

正しく動作しました。更新されたplunkerは次のとおりです。

<!DOCTYPE html>
<html>

  <head>
    <script data-require="angular.js@1.4.0-rc.1" data-semver="1.4.0-rc.1" src="https://code.angularjs.org/1.4.0-rc.1/angular.js"></script>
    <script src="main.es6.js"></script>
  </head>

  <body ng-app="expressionExample">
    <div ng-controller="ExampleController" class="expressions">
    {{hi}}
    </div>
    <cmp></cmp>
  </body>

</html>
于 2015-05-05T21:10:06.593 に答える