这是我的js文件
当我尝试创建一个新控制器时,我收到错误
" Argument' storeController'不是一个功能,未定义"
有人可以帮帮我吗
var myApp = angular.module('bindExample', []);
myApp.controller('commonController', ['$scope', function($scope) {
$scope.customers = [
{ name: 'John Smith', city: 'Pheonix'},
{ name: 'John Doe', city: 'New York'},
{ name: 'Jane Doe', city: 'San Francisco'}
];
}]);
myApp.controller('StoreController', ['$scope', function($scope){
$scope.gems=[
{name: 'abc', price: '110.50', canPurchase: 'false', soldOut: 'true'},
{name: 'xyz', price: '120.50', canPurchase: 'true', soldOut: 'false'}
];
});
HTML代码
<html ng-app="bindExample">
<head>
<script src="js/angular.min.js"></script>
</head>
<body>
Store details
<div ng-controller="StoreController">
<h3 ng-repeat="store in gems">
{{store.name}}<br>
{{store.price}}
</h3>
</div>
<script src="js/homeCtrl.js"/>
</body>
</html>
答案 0 :(得分:0)
您缺少包含您的javascript文件。如果未加载,则角度不知道它。
<html ng-app="bindExample">
<head>
<script src="js/angular.min.js"></script>
<script src="js/yourScript.js"></script> <!-- your script here -->
</head>
<body>
Store details
<div ng-controller="StoreController">
<h3 ng-repeat="store in gems">
{{store.name}}<br>
{{store.price}}
</h3>
</div>
<script src="js/homeCtrl.js"/>
</body>
</html>