1

I have diferents controllers in my app.

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.

Now, I have the menu bar in menu.php, where I use in player.php document, imported with:

<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. 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...

menu.php

<div class="navbar-fixed"  ng-controller="menu2">
  //some html code
</div>

menu.js:

app.controller('menu2', function($scope) {

 $scope.content = '';
});

What am I doing wrong?

Thank you!

1
  • error say that not defined menu but in you sample only InteractiveController and menu2 Commented Jun 7, 2015 at 12:32

2 Answers 2

1

The name of the controller inside the HTML and the JS doesn't match. In html InteractiveController and you named the contoller menu2.

This would fix the problem.

app.controller('InteractiveController', function($scope) {
    $scope.content = '';
});
Sign up to request clarification or add additional context in comments.

3 Comments

ok, thank you. I have just tried: MENU.PHP--> <div class="navbar-fixed" ng-controller="InteractiveController as menu2"> and in MEMU.JS --> app.controller('menu2', function($scope){}); and everithing works ok now :). //// I have another question: If I have another .php with a diferent ng-app name and a diferent ng-controller name; there is a way that I could import the MENU.php?? Thank you.
@Jordi45454, you can define menu in separate module and use it as dependency where you want
so then, where I should define the menu as a separated module? Sorry! I'm new with AngularJS hehe.
0

Have u included your menu controller in html page. Its controller name is mismatched and its not included in that page

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.