index.html中的ng-view部分之前运行良好...它在我将另一个控制器功能添加到角度模块后停止工作。它只有当我删除我用来将上述控制器引用到index.html的脚本时再次工作,这让我感觉在那个业余爱好者无法识别的控制器中可能存在问题...任何人都受到高度赞扬.....(原谅我,如果我做了任何愚蠢的错误,因为我对angularjs和stackoverflow都很新)
下面的是我的index.html .............
<!DOCTYPE html>
<html ng-app="fishingbot">
<head>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/style.css">
<script src="jquery/jquery-3.3.1.js"></script>
<script src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="angular-app/app.js"></script>
<script src="angular-app/bot-list/bot-list-controller.js"></script>
<script src="angular-app/bot-display/bot-display-controller.js"></script>
<script src="angular-app/bot-data-factory/bot-data-factory.js"></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
<script src="bower_components/fusioncharts/fusioncharts.js"></script>
<script src="bower_components/fusioncharts/themes/fusioncharts.theme.zune.js"></script>
<script src="bower_components/fusioncharts-angular/angular-fusioncharts.js"></script>
**// this is the script that refers to above-said controller.....**
////////////////////////////////////////////////////////
<script src="/webapp/chart-data-controller.js"></script>
/////////////////////////////////////////////////////////
<title>Automated Fishing Bot</title>
</head>
<body>
**//ng-view part...this loads a table from another html page.....**
<div class="content-wrapper" ng-view >
</div>
**//this is html part which gets the functionality from controller**
<div ng-controller="chartController">
<fusioncharts width="450"
height="230"
type="bar2d"
id="chart-1"
dataformat="json"
datasource={{data}}>
</fusioncharts>
</div>
</html>
&#13;
给出痛苦的控制器........
angular.module('fishingbot', ['ng-fusioncharts']).controller('chartController',chartController);
function chartController($scope, $http){
var getdata;enter code here
console.log('Check 2');
getData = function(url, callback) {
$http({
method: 'GET',
dataType: 'json',
url: url,
headers: {
"Content-Type": "application/json"
}
}).then(callback);
};
getData('/api/bots', function(response) {
console.log('Check 3');
console.log(response);
var datasource,
doc,
data = [],
linkeddata = [],
chart;
chart = {
caption: "Total Triggers",
showValues: 0,
theme: "zune"
};
console.log(response.data.length);
console.log('Check 4');
for (var _i = 0; _i < response.data.length; _i++) {
doc = response.data[_i];
data.push({
label: doc.BotID,
value: doc.ActiveHours,
link: 'newchart-json-' + _i.toString()
});
console.log('Check 5');
linkeddata.push({
id: _i.toString(),
linkedchart: {
chart: {
caption: 'Triggers of a Fishing bot - '+ doc.BotID,
showValues: 0,
theme: "carbon"
},
data: doc.TriggerData.map(function(ele) {
return {
label: ele.TimeStamp,
value: ele.Triggers
};
})
}
});
&#13;
控制器中的功能也很好用......
index2.html,它应该通过index.html中的ng-view加载,如果上面提到的控制器被删除,确实会加载........
<body>
<h1>THIS IS THROUGH NG-VIEW</h1>
</body>
&#13;
解决
问题似乎是我们不能从不同的脚本添加多个依赖关系到角度模块(虽然我不知道如何工作)...因此删除了&#39; ng-fusioncharts&# 39;来自chartController的依赖项并将其放在另一个脚本中,其中包含&#39; ngRoutes&#39;已配置依赖项。事情开始变得像他们想象的那样......