aru*_*com 2 state-machine angularjs
任何人都可以帮我集成状态机来控制路由吗?
这样做的最佳方法是什么?创建服务?
我需要基本上拦截每个$ location请求,运行状态机并让它弄清楚下一个$ location.path应该是什么.
将问题想象成随着时间的推移而添加和删除的一系列问题.用户偶尔访问一次,将用户的答案对象传递给状态机,状态机会指出要加载的问题.这是我的伪代码,但我需要弄清楚在哪里放置这个或我可以挂钩的事件以确保所有路由请求都通过机器.我需要特定的stateMachine控制器吗?我是否创建了服务?我在哪里使用该服务?我需要覆盖$ locationProvider吗?
$scope.user.answers = [{
id: 32,
answer: "whatever"
},
{
id:33,
answer: "another answer"
}]
$scope.questions = [{
id:32,
question:"what is your name?",
path:"/question/1"
},{
id:34,
question:"how old are you?",
path:"/question/2"
}]
var questions = $scope.questions;
angular.forEach(questions, function(question) {
if(question.id !exist in $scope.user.answers.id) {
$location.path = question.path
break;
});
Run Code Online (Sandbox Code Playgroud)
谢谢
| 归档时间: |
|
| 查看次数: |
5271 次 |
| 最近记录: |