我对 AngularJs 真的很陌生,我找不到如何执行以下操作:
用户正在 quiz.html 页面中回答问题。 每个答案都会添加到“答案”列表中。 在 Controller 中,如果我的“答案”列表包含 4 个答案,我想重定向到 result.html 页面...
if (answers.length === 4) {
???? }
我知道这是一个简单的问题,但我找不到任何简单的答案 谢谢!
最佳答案
您可以使用Angular $location
if (answers.length === 'whatever') {
$location.path("/result")
}
在你的 app.js 中
$routeProvider.when('/result', {
templateUrl: 'templates/result.html',
controller: 'ResultCtrl'
})...
Make sure to inject the $location into your controller.
关于javascript - AngularJS Controller 中基于值的重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28865857/