【发布时间】:2013-02-12 20:20:39
【问题描述】:
这可能是一件微不足道的事情,但我是一个 angularjs 新手。 这是我的 angularjs 控制器代码
function MyCtrl1($scope, $location, $rootScope) {
$scope.$on('$locationChangeStart', function (event, next, current) {
event.preventDefault();
var answer = confirm("Are you sure you want to leave this page?");
if (answer) {
}
});
}
MyCtrl1.$inject = ['$scope', '$location', '$rootScope'];
在next 变量中,我有要重定向的url,确认OK。但是如何在angularjs 中完成这件事。
【问题讨论】:
标签: javascript redirect angularjs angularjs-directive