我很难找出问题所在。AngularJS:参数'Controller as short'不是一个函数,没有定义
为什么这个代码(index.html的)运行
<!DOCTYPE html>
<html ng-app="gemStore">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
<div class="list-group-item" ng-repeat="product in store.products">
<section ng-controller="TabController as tab">
</section>
</div>
</body>
</html>
而
<!DOCTYPE html>
<html ng-app="gemStore">
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
<section ng-controller="TabController as tab">
</section>
</body>
</html>
产生一个错误:'Error:参数 'TabController作为标签' 不是一个函数,在得到未定义错误(本地)“
app.js:
(function() {
var app = angular.module('gemStore', []);
app.controller('StoreController', function() {
this.products = gems;
});
app.controller("TabController", function() {
this.tab = 1;
this.isSet = function(checkTab) {
return this.tab === checkTab;
};
this.setTab = function(setTab) {
this.tab = setTab;
};
});
var gems = [
{
data : 'data'
}
];
})();
非常感谢您提前!
查看您的版本中功能的可用性。 – PSL 2014-10-09 00:20:02