简体   繁体   English

如何在angularjs中将对象数据从一个控制器传递到另一个控制器

[英]how to pass object data from one controller to another controller in angularjs

实际上,我正在尝试在angularjs中填写表格,并且其数据已在其中一个控制器中接收到...我需要将相同的数据传递给另一个需要在另一个网页上显示的控制器

You should make use of angular service to do the same. 您应该使用角度服务执行相同的操作。

Create a service, that will hold model variables. 创建一个将容纳模型变量的服务。

angular.service("dataService", function() {
    this.value1 = "";  
});

Then you can reference that service in your controllers, 然后,您可以在控制器中引用该服务,

angular.controller("myCntrl1", function($scope, dataService) {
    $scope.value1 = dataService.value1;
});


angular.controller("myCntrl2", function($scope, dataService) {
    $scope.value1 = dataService.value1;
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用工厂将数据从一个控制器传递到AngularJS中的另一个控制器 - Using a factory to pass data from one controller to another controller in AngularJS 将对象从控制器传递到另一个控制器angularjs - pass an object from controller to another controller angularjs 如何将一个控制器的值传递给另一控制器? -angularjs - How to pass a value from one controller to another controller? -angularjs AngularJS将数据从控制器传递到另一个控制器 - AngularJS pass data from controller to another controller 如何将数据从一个控制器发送到angularjs中的另一个控制器 - How to send data from one controller to another controller in angularjs AngularJS:使用同一控制器将数据从一个视图传递到另一个视图 - AngularJS : Pass data from one view to another with in same controller 在我的情况下如何将数据从一个控制器传递到另一个控制器 - How to pass data from one controller to another controller in my case AngularJS:如何将整个对象传递给另一个控制器? - Angularjs: how to pass entire object to another controller? 如何在angularjs中将登录数据从一个控制器传递到另一个控制器而不是使用rootscope - how to pass login data from one controller to another other than using rootscope, in angularjs AngularJS-如何在ng-click()上将数据从一个控制器传递到另一个控制器? - AngularJS- How to pass data from one controller to another on ng-click()?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM