[英]When i try to refresh my page i have this error
error .Uncaught SyntaxError: Invalid shorthand property initializer angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.5/ $injector/modul
错误。未捕获的SyntaxError:无效的速记属性初始化程序angular.js:38未捕获的错误:[$ injector:modulerr] http://errors.angularjs.org/1.4.5/ $ injector / modul
This is my app.js code: 这是我的app.js代码:
var myApp = angular.module("myapp", ["ngRoute"]);
myApp.controller("myController", function($scope){
console.log("This is app.js ...........");
$scope.users = [
{username="John" , email="john@mail.com"},
{username="Adam" , email="Adam@adam.com"}
];
});
This is my index.html code: 这是我的index.html代码:
<!DOCTYPE html>
<html lang="en-US">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp" ng-controller="myController">
<div class="container">
<button type="button" class="btn btn-primary pull-right"
data-toggle="modal" data-target="#myModal">Add Product</button>
<h2>Product List</h2>
<table class="table table-striped">
<thead>
<tr>
<th>Index</th>
<th>UserName</th>
<th>Email</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>{{$index+1}}</td>
<td>{{user.username}}</td>
<td>{{user.email}}</td>
<td>
<button type="button" class="btn btn-warning" 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>
</body>
</html>
Fix ng-app="myApp"
to ng-app="myapp"
in html file. 将
ng-app="myApp"
修复为html文件中的ng-app="myapp"
。 check this plunkr 检查这个笨蛋
var myApp = angular.module("myApp", []);
myApp.controller("myController", function($scope){
console.log("This is app.js ...........");
$scope.users = [
{username: "John" , email:"john@mail.com"},
{username:"Adam" , email:"Adam@adam.com"}
];
});
That's not the way to declare an object. 那不是声明对象的方式。 Replace = with :
将=替换为:
$scope.users = [
{username:"Shanto" , email:"shanto@gmail.com"},
{username : "Adam" , email : "Adam@adam.com"}
];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.