我很難找出問題所在。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