W
W
Worddoc2016-03-21 20:02:13
JavaScript
Worddoc, 2016-03-21 20:02:13

The simplest application on Angular does not work?

Hello. I learn Angular by lessons. It is necessary that by clicking on the button, the value that is in the input is assigned to the name variable and displayed instead of Hello World! But something is not assigned to anything, help!

<!doctype html>
<html lang="en" ng-app="Application">
<head>
  <meta charset="utf-8">
  <title>Google Phone Gallery</title>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
  <script>
      var moduleMain = angular.module("Application", []);
      moduleMain.controller("Ctrl", function($scope) {
        $scope.helloName = "Hello World"
        $scope.name = $scope.helloName;
        $scope.mainFunction = function() {
          $scope.name = $scope.text;
        }
      })
  </script>
</head>
<body>

<div ng-controller="Ctrl">
  <h1>{{name}}</h1>
  <input type="text" ng-model="text">
  <input type="button" value="Press it!" ng-click="mainFunction">
</div>

</body>
</html>

Tell me what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JIakki, 2016-03-21
@JIakki

Try moving the scripts to the bottom of the page

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question