私はデモを作成していますが、私はscript.js
ファイルのコントローラを使用していますが、動作していません。角度コントローラ機能が動作していません。エラー:[ng:areq]
HTMLコード:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-app>
<div ng-controller="simpleController">
<strong>First name:</strong> {{firstName}}<br />
<strong>Last name:</strong> <span ng-bind="lastName"></span><br />
<strong>Full name:</strong> {{getFullName()}}<br />
</div>
</body>
</html>
script.jsコンソールで
var simpleController = function ($scope)
{
// Initialize the model variables
$scope.firstName = "John";
$scope.lastName = "Doe";
// Define utility functions
$scope.getFullName = function()
{
return $scope.firstName + " " + $scope.lastName;
};
};
エラー:あなたが好きなアプリを定義する必要があります
Error: [ng:areq] http://errors.angularjs.org/1.5.7/ng/areq?p0=simpleController&p1=not%20a%20function%2C%20got%20undefined
O/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:6:412
[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:22:508
[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:23:78
gf/this.$get</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js:89:273
https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js
Line 117
スニペットが正常に機能している場合は、「回答済み」とマークしてください。 –