AngularJS-什么是$transitions?
目前正在使用AngularJS+NodeJS应用程序,突然我看到以下代码:AngularJS-什么是$transitions?,angularjs,angular-ui-router,Angularjs,Angular Ui Router,目前正在使用AngularJS+NodeJS应用程序,突然我看到以下代码: $transitions.onStart({exiting: 'orders.view'}, function(trans) { Socket.emit('orders:leave', {id_order: trans.params('from').id_order}); }); 帮我找到$transitions午餐吃什么 谢谢 答案编辑后: 对于那些最终在这里着陆的人来说,你基本上可
$transitions.onStart({exiting: 'orders.view'}, function(trans) {
Socket.emit('orders:leave', {id_order: trans.params('from').id_order});
});
帮我找到$transitions
午餐吃什么
谢谢
答案编辑后: 对于那些最终在这里着陆的人来说,你基本上可以在这些过渡中做任何你想做的事情;包括在退出X状态时做一些事情
'use strict';
// Configuring the orders module
angular.module('orders').run(['Menus','MODULE_LIST', 'Authentication', '$transitions', 'Socket', '$templateCache',
function(Menus, MODULE_LIST, Authentication, $transitions, Socket, $templateCache) {
$transitions.onStart({exiting: 'orders.view'}, function(trans) {
alert('Alert function has stopped you from going further BEEP BOOP')
Socket.emit('orders:leave', {id_order: trans.params('from').id_order});
});
var stlViewPopoverHtml =
'<div>' +
'<img ng-src="{{url}}" height="{{height}}" width="{{width}}">' +
'</div>';
$templateCache.put('stl-preview-popover.html', stlViewPopoverHtml);
}
]);
“严格使用”;
//配置订单模块
angular.module('orders')。运行(['Menus','module_LIST','Authentication','$transitions','Socket','$templateCache',
功能(菜单、模块列表、身份验证、$transitions、Socket、$templateCache){
$transitions.onStart({正在退出:'orders.view'},函数(trans){
警报('警报功能已阻止您继续发出嘟嘟声')
emit('orders:leave',{id_order:trans.params('from').id_order});
});
var stlViewPopoverHtml=
'' +
'' +
'';
$templateCache.put('stl-preview-popover.html',stlviewpopooverhtml);
}
]);
这是UI路由器的一部分。您可以在此处找到文档:
例如,$transitions.onStart
将注册一个转换挂钩,每当您从一个状态移动到另一个状态时,该挂钩将触发提供的函数。在您的示例中,它仅在退出提供的状态时触发,在您的情况下,该状态为orders.view
总结您提供的代码将执行的操作:当退出
orders.view
状态时,一旦状态转换开始,就会触发Socket.emit
。没问题,乐意帮助!