クリアボタンをクリックしたときにテキストフィールドをクリアしようとしています。ここで私のシステムで試したコードがありますが、私はまだ結果を得ていません。 私がAngularに慣れていないので、私は愚かな間違いをお詫びします。クリアボタンの角度JS
HTMLコード
<!DOCTYPE html>
<html>
<head>
<title>Creation Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="../controllers/clearbutton.js"></script>
</head>
<body>
<div class="container">
<h2 style="text-align: center"><b>Create User</b></h2>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title" style="text-align: center">
Enter your details
</h4>
</div>
<div class="panel-body">
<div class="row" ng-app="myApp" ng-controller="clear">
<div class="col-sm-4 form-group col-md-4 col-xs-12">
<div class="input-group">
<div class="input-group-addon"><i class="glyphicon glyphicon-user"></i></div>
<input type="text" class="form-control" placeholder="Name" name="callername" ng-model="callername"/>
</div>
</div>
<div class="col-sm-4 form-group col-md-4 col-xs-12">
<div class="input-group">
<div class="input-group-addon"><i class="glyphicon glyphicon-user"></i></div>
<input type="text" class="form-control" placeholder="User Code" name="usercode" ng-model="usercode" />
</div>
</div>
<div class="col-sm-4 form-group col-md-4 col-xs-12">
<div class="input-group">
<div class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></div>
<input type="text" class="form-control" placeholder="Email" name="email" ng-model="email" />
</div>
</div>
</div>
<div class="pull-right">
<button type="submit" class="btn btn-primary ">Invite</button>
<button type="clear" class="btn btn-default" ng-click="clear()">Clear</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
角度JSコード
angular.module('myApp', [])
.controller('clear', ['$scope', function ($scope) {
$scope.clear = function() {
$scope.callername = "";
$scope.volunteercode = "";
$scope.email = "";
console.log($scope.callername);
console.log($scope.usercode);
console.log($scope.email);
};
}]);
ここで明確な関数を呼び出していますか? – SaiUnique
あなたは 'クリア 'ボタンを使ってどこを見ることができませんか? 'user:{'allername':' '、' volunteercode ':' '...}'のようなもので、より良いアプローチです。 –
クリアボタンはどこですか? – Jigar7521