Angular.jsを初めて使用していて、サーバーにフォームデータを送信しようとしていますが、angular.jsにエラーが発生します:13424エラー:[ng:areq]。私はスタックオーバーフローで利用可能な多くの答えを試してみましたが、私は私の問題の答えを見つけることができません。 (レジスタ用)Angular.jsを使用してフォームデータを渡すことができません
index.view.html
<div class="col-md-6 col-md-offset-3" >
<input type="text" ng-model="fname" placeholder="Enter the name :"required >Fristname
<br> <br>
button type="button" class="btn btn-success navbar-btn" ng-click=register()>Register </button>
</div>
index.controller.js
(function()
{
angular
.module('app')
.controller('register.IndexController', function($scope,$http)
{
$scope.register= function()
{
$http.post('http://localhost:9000/user/register', {firstName : $scope.fname}).success(function(response)
{ console.log($scope.fname);
})
}
})
});
index.htmlを
<!DOCTYPE html>
<html ng-app="app">
<head>
<title>AngularJS JWT Authentication Example & Tutorial</title>
<!-- bootstrap css -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<!-- application css -->
<link href="app-content/app.css" rel="stylesheet" />
</head>
<!-- HEADER AND NAVBAR -->
<header>
<nav class="navbar navbar-default">
<nav class="cf" ng-include="'nav/index.view.html'" ng-controller="Main.IndexController"></nav>
</nav>
</header>
モジュールアプリケーションを別の場所に定義しましたか?そうでない場合は、このindex.controller.js '.module( 'app'、[])'が必要です。それが(角カッコで囲まれた)別の場所で定義されている場合は、一度だけそれがあることを確認してください – theTaoOfJS
Main.IndexControllerとregister.IndexController ... –
@theTaoOfJSはい私はそれぞれの依存関係を持つ角括弧で定義していますので、他のコントローラファイルでも私は定義しました。その部分は含まれていません。[] – HebleV