[英]When i try to refresh my page i have this error
錯誤。未捕獲的SyntaxError:無效的速記屬性初始化程序angular.js:38未捕獲的錯誤:[$ injector:modulerr] http://errors.angularjs.org/1.4.5/ $ injector / modul
這是我的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"}
];
});
這是我的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>
將ng-app="myApp"
修復為html文件中的ng-app="myapp"
。 檢查這個笨蛋
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"}
];
});
那不是聲明對象的方式。 將=替換為:
$scope.users = [
{username:"Shanto" , email:"shanto@gmail.com"},
{username : "Adam" , email : "Adam@adam.com"}
];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.