我在参数列表后面收到错误:Uncaught SyntaxError:missing) 和未捕获的错误:[$ injector:modulerr]
我不知道我犯了什么错误,任何人都可以检查我的问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script >
var myApp=angular.module("myapp",[]);
myApp.controller("mycontroller",function($scope){
console.log("vinoth");
$scope.users=[{Firstname:"Vinoth",Lastname:"Kumar",Email:"VNO@example.com"},
{Firstname:"Vj",Lastname:"Krish",Email:"Vj@example.com"},
{Firstname:"Vk",Lastname:"Khali",Email:"Vk@example.com"}];
});
</script>
</head>
<body ng-app="myApp" ng-controller="mycontroller">
<div class="container">
<hr>
<button type="button" class="btn btn-primary btn-lg pull-right" data-toggle="modal" data-target="#myModal">Add</button>
<h1>All users</h1>
<span class="clearfix"></span>
<hr>
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>{{user.Firstname}}</td>
<td>{{user.Lastname}}</td>
<td>{{user.Email}}</td>
<td><button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModalEdit">Edit</button></td>
<td><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModalDelete">Delete</button></td>
</tr>
</tbody>
</table>
</div>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add New</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" >First Name:</label>
<div class="col-sm-10">
<input class="form-control" id="pwd" placeholder="Enter First Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" >Last Name:</label>
<div class="col-sm-10">
<input class="form-control" id="pwd" placeholder="Enter Last Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" >Email:</label>
<div class="col-sm-10">
<input class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-success">Save</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div><div class="modal fade" id="myModalEdit" role="dialog">
<div class="modal-dialog"><!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit</h4>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" >First Name:</label>
<div class="col-sm-10">
<input class="form-control" id="pwd" placeholder="Enter First Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" >Last Name:</label>
<div class="col-sm-10">
<input class="form-control" id="pwd" placeholder="Enter Last Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" >Email:</label>
<div class="col-sm-10">
<input class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" class="btn btn-success">Save</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModalDelete" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Are you Sure want to delete?</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success">Yes</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
任何人都可以告诉我答案
谢谢
Vinoth
答案 0 :(得分:1)
funtion
中的错字错误。使用function
:
var myApp = angular.module(&#34; myApp&#34;,[]); myApp.controller(&#34;&myController的#34;,函数($范围){
console.log("vinoth");
$scope.users=[{Firstname:"Vinoth",Lastname:"Kumar",Email:"VNO@example.com"},
{Firstname:"Vj",Lastname:"Krish",Email:"Vj@example.com"},
{Firstname:"Vk",Lastname:"Khali",Email:"Vk@example.com"}];
});
2. var myApp=angular.module("myApp",[]);
处的触摸错误必须为myApp
而不是myapp
。
示例:强>
var myApp=angular.module("myApp",[]);
myApp.controller("mycontroller",function($scope){
console.log("vinoth");
$scope.users=[{Firstname:"Vinoth",Lastname:"Kumar",Email:"VNO@example.com"},
{Firstname:"Vj",Lastname:"Krish",Email:"Vj@example.com"},
{Firstname:"Vk",Lastname:"Khali",Email:"Vk@example.com"}];
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="mycontroller">
<ul ng-repeat=" x in users">
<li>{{x.Email}}</li>
</ul>
</div>
&#13;