重定向在以下代码中不起作用。我的console.log()
工作正常,但网址不会更改。不用说,我很困惑为什么。我已经更改了URL,这是我的应用程序的另一部分,它运行良好。
angular.module('workstation.process.approval', [
/* Dependencies */
'workstation.services'
]).
config(['$routeProvider', function($routeProvider) {
/* URL mappings */
$routeProvider.
when('/approval', {templateUrl: 'partials/loading.htm', controller: 'ApprovalCtrl'}).
when('/approval/dashboard', {templateUrl: 'partials/approval/dashboard.htm', controller: 'ApprovalCtrl'})
}]).
controller('ApprovalCtrl', ['$scope', '$cookieStore', 'WorkflowProcessService', 'socketUrl', '$location', function ($scope, $cookieStore, WorkflowProcessService, socketUrl, $location) {
var socket = portal.open(socketUrl+'/socket/workstation/approval');
socket.on({
open: function () {
this.send('getDashboard', {
workstationUuid: $cookieStore.get('workstationUuid')
}, function(r) {
$scope.dashboard = r;
console.log('swap-path', r);
$location.path('/approval/dashboard'); //NOT WORKING
});
},
close: function (reason) {
console.log(reason);
}
});
}]);
答案 0 :(得分:1)
尝试在更改路径后添加$ scope。$ apply()。回调上的套接字在Angular之外调用,因此您可能需要告诉Angular运行摘要周期以注意更改。 - Mark Rajcok 5月14日21:18
它对我有用,谢谢
答案 1 :(得分:-1)