我想将数据从一个控制器传递给另一个控制器 这是我的职能:
app.controller('formVacationController', function($scope, $state, $rootScope) {
// we will store all of our form data in this object
$scope.formData = {};
$rootScope.globalAnswers = "";
var point;
checkAnswer = function(){
if($scope.formData.mashhad === "mashhad"){
point = 50;
}
else if($scope.formData.kish === "kish"){
point = 100;
}
else if($scope.formData.shomal === "shomal"){
point = 70;
} else if($scope.formData.shiraz === "shiraz"){
point = 60;
}
}
$scope.nextStep = function(){
checkAnswer();
$rootScope.globalAnswers = point;
$state.go('form.job');
}
});
和另一个:
var point;
point = $rootScope.globalAnswers;
我无法从第一个控制器获得价值。
我错过了什么吗?
答案 0 :(得分:2)
你可以使用这样的工厂:
public interface I {
default void a(){
//implementation
}
default void b(){
//implementation
}
default void c(){
//implementation
}
//97 more
}
public class A implements I{
@override
public void a() {
}
}
public class B extends A {
@override
public void b() {
}
public class C extends B {
@override
public void c() {
}
}
然后在你的控制器中调用setPoint(point)来存储点,并在另一个控制器中调用getPoint()以进行检索。