0

Here is a simple demo Html but the main concern is same that I had to transfer the current object of the ng-repeat "result.status" value to the other module working on a different controller and on a different partial html included on the main.html

Hope I have clarified the situation here

angular.module('one',[])
.controller('myCtrl',[function(){
 var thisOne=this;
 thisOne.item=[
  {id:1,Name:'Harish',city:'delhi',Status:false},
  {id:2,Name:'Malkeet',city:'delhi',Status:true},
  {id:3, Name:'Anash',city:'delhi',Status:false}
  ];
 
 }]); 



/*now the module two starts for the  different html*/
angular.module('two',[])
.controller('myCtrl2',[function(){
 }]); 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="one">
<div ng-controller="myCtrl as prime">
  <div ng-repeat="result in prime.item">
    <p ng-bind="result.name"></p>
    <p ng-bind="result.city"></p>
    <ng-include src="'different.html'"></ng-include> 
    </div>
  </div>
</div>

<!--different.html will be like this certain code-->

<div ng-app="two">
<div ng-controller="myCtrl2 as omega">
<p><!--here i want to print the  "result.Status of myCtrl"--></p>
  </div>
  </div>
michelem
  • 14,430
  • 5
  • 50
  • 66
  • 1
    Can I ask why you need two apps? – michelem Jul 10 '15 at 11:49
  • Its the requirement for my work !!! – harish kumar Jul 10 '15 at 11:52
  • This result.status of myCtrl has to trigger a function in the different.html – harish kumar Jul 10 '15 at 11:53
  • Two angular app can't communication directly until you inject one into another. And I can see that you are trying to bootstrap two app in single page this will also not work. Because ever bootstrap app will have difference instance. The only possible solution I can see is, you can create a data service at window object which will be accessible across app. – dhavalcengg Jul 10 '15 at 12:04
  • Use a service, which is _persistent_. Using two apps will cause some maybe unexpected issues: http://stackoverflow.com/questions/16725392/share-a-single-service-between-multiple-angular-js-apps – Sergiu Paraschiv Jul 10 '15 at 12:19
  • This is a bit unrelated, but we stopped using different modules on our project. Everything goes into the "app" module and then controllers communicate via services, when needed. I completely understand the "reusability" part, but we had a LONG discussion about this, and it doesn't seem to be needed in most cases. – VSO Jul 10 '15 at 12:40
  • If you are truly bound to two apps, what are your browser requirements for your users. Are they required to be HTML5 compliant. – tuckerjt07 Jul 10 '15 at 15:04

0 Answers0