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);
  };
}]);
Jerry Stratton
  • 3,287
  • 1
  • 22
  • 30
Ben Pearce
  • 6,884
  • 18
  • 70
  • 127

2 Answers2

0

You are using Angular 2.0 reference

Once I updated the reference to 1.4.0-rc1

It worked correctly. Here is the updated 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>
kanchirk
  • 912
  • 2
  • 13
  • 29
0

Hi you are using in your code Angular 2.0 plugin

you have written angular 1 syntax, so you have to write angular 1.4.0 plugin in html , then it will may work perfectly