Encountering a specific error mentioned in the title.
I organized models and controllers into distinct files saved under models and controllers folders respectively.
Upon trying to establish a connection between them, I received an error stating "ng:areq Bad Argument "Argument 'rightPaneCtrl' is not a function, got undefined".
What could be potentially incorrect with my code?
index.html↓
<html ng-app="rightpaneMVC" data-framework="typescript">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<!--<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>
<script src="//code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>-->
<style>
.item_list {
display: flex;
flex-direction: row;
padding-left: 0;
}
.item_list > li {
list-style-type: none;
cursor: pointer;
border: 1px solid black;
padding: 0.3rem;
width: 100px;
margin-right: 0.2rem;
}
</style>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
</head>
<body>
<div id="tab-category" ng-controller="rightPaneCtrl">
<!--<ul>
<li ng-repeat="tab in vm.tabs track by $index" ng-click="vm.handleTabClick(tab,$index)">
<a href="#{{ tab.tabID }}">{{ tab.name }}{{ tab.tabID }}</a>
<span ng:class="{true:'ui-icon ui-icon-circle-close ui-closable-tab', false:''}[$index!=0]"></span>
</li>
</ul>-->
<hr />
<tabset ng-init="startActive = true">
<tab ng-repeat="tab in vm.tabs track by $index" active="startActive">
<tab-heading ng-switch="tab.isClosable">
<div ng-switch-when=true>
{{ tab.name }} <a ng-click="vm.handleTabClick($index)" href=''><i class="icon-remove"></i></a>
</div>
<div ng-switch-when=false>
{{ tab.name }}
</div>
</tab-heading>
<ul class="item_list" ng-switch="tab.categoryTypeString">
<li ng-switch-when="DAI" ng-repeat="item in tab.items" ng-click="vm.handleItemClick(item)">
<img ng-src="{{item.thumbnailPath}}"><br />
<p align="center">{{ item.categoryName }}</p>
</li>
<li ng-switch-when="CHU" ng-repeat="item in tab.items" ng-click="vm.handleItemClick(item)">
<img ng-src="{{item.thumbnailPath}}"><br />
<p align="center">{{ item.categoryName }}</p>
</li>
<li ng-switch-default ng-repeat="item in tab.items">
<img ng-src="{{item.thumbnailPath}}"><br />
<p align="center">{{ item.categoryName }}</p>
</li>
</ul>
</tab>
</tabset>
<!--<div ng-repeat="tab in vm.tabs track by $index" id="{{ tab.tabID }}">
<ul class="item_list" ng-switch="tab.categoryTypeString">
<li ng-switch-when="DAI" ng-repeat="item in tab.items" ng-click="vm.handleItemClick(item)"> {{ item.categoryName }}</li>
<li ng-switch-when="CHU" ng-repeat="item in tab.items" ng-click="vm.handleItemClick(item)"> {{ item.categoryName }}</li>
<li ng-switch-default ng-repeat="item in tab.items"> {{ item.categoryName }}</li>
</ul>
</div>-->
</div>
<script src="//code.angularjs.org/1.4.1/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.4.0/ui-bootstrap-tpls.min.js"></script>
<script src="Application.js"></script>
<script src="controllers/RightPaneCtrl.js"></script>
</body>
</html>
Application.ts↓
module rightpane {
'use strict';
angular.module('rightpaneMVC', ['ui.bootstrap']);
angular.module('rightpaneMVC').controller('rightPaneCtrl', RightPaneCtrl);
}
RightPaneCtrl.ts↓
module rightpane {
'use strict';
export class RightPaneCtrl {
public static $inject = ['$scope', '$http'];
private mModel = new RightPaneTabList;
public constructor(
private $scope: any,
private $http: ng.IHttpService) {
$scope.vm = this;
}
public get tabs(): Tab[] {
return this.mModel.tabs;
}
handleItemClick(aItem: Item): void {
console.log('Item clicked');
this.mModel.addCategory(aItem);
}
handleTabClick(tabIndex: number): void {
console.log('Tab clicked');
this.mModel.tabs.splice(tabIndex, 1);
}
}
}
Directory Structure↓
root
|-index.html
|-controllers
|-RightPaneCtrl.ts