A
A
ASultonov2015-08-10 17:10:34
JavaScript
ASultonov, 2015-08-10 17:10:34

Why is there an error when using as-syntax in AngularJS?

In short, here is the HTML

<!DOCTYPE html>
<html lang="en" ng-app="app">
  <head>
    <meta charset="UTF-8">
    <title>as-синтаксис</title>
    <script src="js/angular.min.js"></script>
  </head>

  <body>
    <div ng-controller="Controller as ctrl">
      {{ctrl.hello}}
    </div>

    <script src="js/test.js"></script>
  </body>
</html>

... and here is the js
app = angular.module('app', []);

app.controller('Controller', function() {
  this.hello = 'Hell... what the hell???';
});

Error in console: "Argument 'Controller as ctrl' is not a function". I understand what that means, but I don't understand why.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-08-10
@ASultonov

well, because it's
not
app.controller('Controller', function() {

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question