i want to use ng-app in another ng-app (nested).
and i have controller for each app ,controllers have same name
code is here :
<!DOCTYPE html>
<html>
<head>
<script src="/scripts/angular.js"></script>
<script src="/scripts/Controller1.js"></script>
<script src="scripts/Controller2.js"></script>
</head>
<body ng-app="MasterApp">
<div ng-controller="myController as myCtr">
{{myCtr.testValue}} ---> controler 1
<div ng-app="DetailApp">
<div ng-controller="myController as myCtr">
{{myCtr.testValue}} ----> controller 2
</div>
</div>
</div>
</body>
</html>
Controlle1.js Code :
var MasterApp = angular.module("MasterApp", ["DetailApp"]);
MasterApp.controller("myController", function ()
{
var myCtr = this;
myCtr.testValue = " a value from Master App ";
});
Controller2.js Code :
var DetailApp = angular.module("DetailApp", []);
DetailApp.controller("myController", function ()
{
var myCtr = this;
myCtr.testValue = " a value from Detail App ";
});
now! controller 2 return value of controller 1!
Result :
a value from Master App
a value from Master App
this is my problem, any idea?