I'm having a hard time to figure out what the problem is.
Why does this code (index.html) run
<!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>
while
<!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>
produces a error: ´Error: Argument 'TabController as tab' is not a function, got undefined at Error (native)´
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'
}
];
})();
Thank you very much in advance!