如何将数据从一个控制器现有对象传输到角度js中的不同控制器

时间:2015-07-10 11:47:12

标签: angularjs

这是一个简单的演示Html,但主要关注的是我必须转移ng-repeat" result.status"的当前对象。值为处理不同控制器的另一个模块以及main.html上包含的不同部分html

希望我已经澄清了这里的情况



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>
&#13;
&#13;
&#13;

0 个答案:

没有答案