Jquery Angular js控制器未正确加载
我正在开发一个混合了jquery和angularjs的web,出于某种原因,我不能放弃使用jquery和单独使用angularjs。情况是这样的 我在我的网站的左侧有一个导航栏,单击该按钮将使用ajax刷新指定div DOM(RHS)处的内容,对于RHS处的内容,我已加载angularjs,并使用jquery getScript显示我的内容 我的controller.js中有以下内容Jquery Angular js控制器未正确加载,jquery,angularjs,controller,Jquery,Angularjs,Controller,我正在开发一个混合了jquery和angularjs的web,出于某种原因,我不能放弃使用jquery和单独使用angularjs。情况是这样的 我在我的网站的左侧有一个导航栏,单击该按钮将使用ajax刷新指定div DOM(RHS)处的内容,对于RHS处的内容,我已加载angularjs,并使用jquery getScript显示我的内容 我的controller.js中有以下内容 /***angularjs controller***/ var
/***angularjs controller***/
var testApp = angular.module('testApp', []).controller('testController', function ($scope) {
debugger;
$scope.dataIs= [
{'name': 'Nexus S',
'snippet': 'Fast just got faster with Nexus S.'},
{'name': 'Motorola XOOM? with Wi-Fi',
'snippet': 'The Next, Next Generation tablet.'},
{'name': 'MOTOROLA XOOM?',
'snippet': 'The Next, Next Generation tablet.'}
];
//show table of content
Tbl.fadeOut().delay(1000).fadeIn(function(){});
以及以下观点
<div ng-app="testApp" class="row">
<table class="table table-striped table-hover">
<tr>
<th class="col-md-1"></th>
<th class="col-md-1">colA</th>
<th class="col-md-1">colB</th>
<th class="col-md-2">colC</th>
<th class="col-md-1">colD</th>
<th class="col-md-2">colE</th>
</tr>
<tbody ng-controller="testController">
<tr ng-repeat="dataI in dataIs">
<td>{{dhcpI.name}}</td>
<td>{{dhcpI.name}}</td>
<td>haha</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
外部html(更新div)
{{1+2}}
您是否在html文件中使用脚本标记来加载控制器?例如,请提供更多关于您的应用程序上下文的信息…谢谢Carl,我已经用更简单的示例更新了关于问题的线程,我认为这将是问题的原因…仍然无法找到解决方案,为什么第二次加载不起作用…当您再次单击按钮时,您的控制台是否记录了“点击”?再次感谢Carl的回答,是的,它确实显示了“点击”,但控制台窗口中显示了以下错误警告:尝试多次加载角度。
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="./test.js"></script>
</head>
<body>
<button id="testBtn">Click</button>
<div id="contentPane"></div>
</body>
</html>
$(function(){
$("button#testBtn").click(function(){
console.log('click');
$("div#contentPane").load("./remote.php", function(){
$.getScript("./angular.js",function(){
});
});
});
});
<html>
<body>
<div ng-app>
{{1+2}}
</div>
</body>
</html>