[英]AngularJS error with nested controllers
I have diferents controllers in my app. 我的应用程序中有不同的控制器。
player.php: player.php:
<html ng-app="decibels-interactive" lang="en">
<body ng-controller="InteractiveController as interactCtrl">
player.php have its respective player.js with its .controller running correctly. player.php具有各自的player.js ,其.controller正常运行。
Now, I have the menu bar in menu.php, where I use in player.php document, imported with: 现在,我在menu.php中有菜单栏,在player.php文档中使用了该菜单栏,并通过以下方式导入:
<html ng-app="decibels-interactive" lang="en">
<body ng-controller="InteractiveController as interactCtrl">
<?php include('includes/menu.php'); ?>
//here some html code
</body>
</html>
Now, I am trying to create a menu.js without success. 现在,我尝试创建一个menu.js失败。 I get the next error:
我收到下一个错误:
Error: [ng:areq] http://errors.angularjs.org/1.2.25/ng/areq?p0=menu&p1=not%20a%20function%2C%20got%20undefined ... 错误:[ng:areq] http://errors.angularjs.org/1.2.25/ng/areq?p0=menu&p1=not%20a%20function%2C%20got%20undefined ...
menu.php menu.php
<div class="navbar-fixed" ng-controller="menu2">
//some html code
</div>
menu.js: menu.js:
app.controller('menu2', function($scope) {
$scope.content = '';
});
What am I doing wrong? 我究竟做错了什么?
Thank you! 谢谢!
The name of the controller inside the HTML and the JS doesn't match. HTML和JS中的控制器名称不匹配。 In html
InteractiveController
and you named the contoller menu2
. 在html
InteractiveController
,您将menu2
命名为。
This would fix the problem. 这样可以解决问题。
app.controller('InteractiveController', function($scope) {
$scope.content = '';
});
Have u included your menu controller in html page. 您是否将菜单控制器包含在html页面中。 Its controller name is mismatched and its not included in that page
它的控制器名称不匹配,并且不在该页面中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.