javascript文件没有要求

问题描述:

我正在写.HTML代码,并在此我对js文件名作为调用chart_buttons.jsjavascript文件没有要求

HTML代码:

<html ng-app> 
    <head> 
<title> 
    Chart 
</title> 
<!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> --> 
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> 
<script src="http://code.highcharts.com/highcharts.js"></script> 
<script src="http://code.highcharts.com/modules/exporting.js"></script> 
<script type="text/javascript" src="chart_buttons.js"></script> 
    </head> 
<body ng-controller="Channels"> 
<p>Set: 
    <label ng-repeat="n in [0,1]"> 
    <input type="radio" name="pageSet" ng-value="n"/>{{n}} 
    </label> 
</p> 
<p>Page: 
    <label ng-repeat="n in [0,1,2,3]"> 
    <input type="radio" name="pageNumber" ng-model="$parent.pageNumber" ng-value="n" /> {{n}} 
    </label> 
</p> 
<ul> 
<li ng-repeat="channel in channels | limitTo: groupSize * ((groupSize * pageSet) + pageNumber + 1) | limitTo: -groupSize"> 
    <p>{{channel.id}}</p> 
    </li> 
</ul> 
</body> 
</html> 

我的Java代码,纸条

chart_buttons.js

function Channels($scope) { 
alert("hiiii"); 
$scope.groupSize = 4; 
$scope.pageSet = 0; 
$scope.pageNumber = 0; 
$scope.channels = [ 
    {"id": "Ch-001"}, {"id": "Ch-002"}, {"id": "Ch-003"}, {"id": "Ch-004"}, 
    {"id": "Ch-005"}, {"id": "Ch-006"}, {"id": "Ch-007"}, {"id": "Ch-008"}, 
    {"id": "Ch-009"}, {"id": "Ch-010"}, {"id": "Ch-011"}, {"id": "Ch-012"}, 
    {"id": "Ch-013"}, {"id": "Ch-014"}, {"id": "Ch-015"}, {"id": "Ch-016"}, 
    {"id": "Ch-017"}, {"id": "Ch-018"}, {"id": "Ch-019"}, {"id": "Ch-020"}, 
    {"id": "Ch-021"}, {"id": "Ch-022"}, {"id": "Ch-023"}, {"id": "Ch-024"}, 
    {"id": "Ch-025"}, {"id": "Ch-026"}, {"id": "Ch-027"}, {"id": "Ch-028"}, 
    {"id": "Ch-029"}, {"id": "Ch-030"}, {"id": "Ch-031"}, {"id": "Ch-032"} 
]; 
} 
angular.module('app', []).controller('Channels', Channels); 
angular.bootstrap(document.body, ['app']); 

但是当我执行的代码它没有显示ASY输出... 因此我在.js文件中发出警报,但它也没有显示警报。所以任何一个可以指导我在哪里,我在编码请

+0

移动从功能(或更好的外部警报出了错,离开只警觉)。控制台中是否有错误? – Justinas 2014-09-19 12:10:18

+1

有你包括角js文件,因为我没有看到任何在你的HTML – 2014-09-19 12:11:22

+0

不,我没有添加任何角度js文件。是否需要添加?因为我没有链接。 – user2099759 2014-09-19 12:26:36

尝试把脚本的HTML的结束或包裹你的函数文档中的准备功能

+0

为什么将函数包装到docready中?并没有什么区别,如果功能是在页眉或页脚,它仍然可以称为 – Justinas 2014-09-19 12:11:09

+0

谢谢你这么多,我加$(文件)。就绪()。它会去.js文件,但它不显示任何输出。 ü可以请Ÿ它没有显示输出 – user2099759 2014-09-19 12:16:57

+0

@Justinas这使得如果你把它的头部或底部,如果你不使用文档准备功能的巨大不同。如果将它放在最下面,则在加载内容之后调用这些文件。因此,如果您操纵内容并将其放入头部,则会出现错误(当不使用doc.ready时) – 2014-09-19 14:43:16