如果我在路线上指定三名警卫,似乎所有警卫都会立即进行评估.
{path: '', component: OptionsComponent, canActivate: [ GuardOne, GuardTwo, GuardThree]}
我遇到的问题是我不希望GuardTwo在GuardOne完成之前运行.有没有办法实现这个目标?
在大多数样品含有使用码为NG-文件上传的小提琴(的https://github.com/danialfarid/ng-file-upload)之类的一个在(http://jsfiddle.net/danialfarid/maqbzv15/1118 /),上传响应回调函数将其代码包装在$timeout服务调用中,但这些调用没有传入任何延迟参数.
$timeout(https://docs.angularjs.org/api/ng/service/ $ timeout)的Angular.js文档表明延迟是可选的,但是为什么要调用$timeoutif if not not delay code is 跑.换句话说,而不是以下,为什么不在之后做一个:
//inject angular file upload directives and services.
var app = angular.module('fileUpload', ['ngFileUpload']);
app.controller('MyCtrl', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $timeout) {
$scope.uploadPic = function(file) {
file.upload = Upload.upload({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
data: {username: $scope.username, file: file},
});
file.upload.then(function (response) {
$timeout(function () {
file.result = response.data;
});
}, function (response) {
if (response.status > 0)
$scope.errorMsg = response.status + …Run Code Online (Sandbox Code Playgroud)