Javascript 两个控制器之间的Angularjs回调
您好,我有以下控制器,点击$scope.choose按钮后调用。 $scope.choose调用另一个页面“/detail”,使用then函数在选择项后等待回调Javascript 两个控制器之间的Angularjs回调,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,您好,我有以下控制器,点击$scope.choose按钮后调用。 $scope.choose调用另一个页面“/detail”,使用then函数在选择项后等待回调 App.controller('itemController', function ($scope, itemRepository, $location, chooseService) { $scope.choose = function () { $location.path('/detail').then(
App.controller('itemController', function ($scope, itemRepository, $location, chooseService) {
$scope.choose = function () {
$location.path('/detail').then(
$scope.test =ChooseService.getItem());
};
});
在“/detail”页面中,当选择项目时,单击提交按钮,将行值添加到服务中
$scope.submit = function(item) {
ChooseService.addChoose(item);
};
App.service("ChooseService", function () {
var choose = [];
this.addChoose = function (newObj) {
binChoose.push(newObj);
};
this.getChoose = function () {
return choose;
};
});
这就是服务
$scope.submit = function(item) {
ChooseService.addChoose(item);
};
App.service("ChooseService", function () {
var choose = [];
this.addChoose = function (newObj) {
binChoose.push(newObj);
};
this.getChoose = function () {
return choose;
};
});
第一页的Html部分isplunker用于第一页的Html
我面临的问题是,在原始itemController中,它没有收到来自“/detail”控制器中的$scope.submit的回调
请让我知道如何修复此代码,以便在服务中加载$scope.submit调用值后,它将返回到上面的$location.path。您能给我看一些HTML吗?我添加了HTML,这是按下Choose的页面的插件,它将转到另一个页面,其中列出了数据行并返回和填充行谢谢