节点和角度.我有一个MEAN堆栈身份验证应用程序,我在成功登录时设置JWT令牌,如下所示,并将其存储在控制器的会话中.通过服务拦截器将JWT令牌分配给config.headers:
var token = jwt.sign({id: user._id}, secret.secretToken, { expiresIn: tokenManager.TOKEN_EXPIRATION_SEC });
return res.json({token:token});
Run Code Online (Sandbox Code Playgroud)
authservice.js拦截器(省略requestError,response和responseError):
authServices.factory('TokenInterceptor', ['$q', '$window', '$location','AuthenticationService',function ($q, $window, $location, AuthenticationService) {
return {
request: function (config) {
config.headers = config.headers || {};
if ($window.sessionStorage.token) {
config.headers.Authorization = 'Bearer ' + $window.sessionStorage.token;
}
return config;
}
};
}]);
Run Code Online (Sandbox Code Playgroud)
现在我想从令牌中获取登录的用户详细信息,我该怎么做?我尝试如下,不工作.当我从Users.js文件记录错误时,它说"ReferenceError:headers not defined"
authController.js:
$scope.me = function() {
UserService.me(function(res) {
$scope.myDetails = res;
}, function() {
console.log('Failed to fetch details');
$rootScope.error = 'Failed to fetch details';
})
};
Run Code Online (Sandbox Code Playgroud)
authService.js:
authServices.factory('UserService',['$http', function($http) …
Run Code Online (Sandbox Code Playgroud) 我想在Angular中注销时关闭所有对话框(mat-dialog,bootstrap modals和sweet alert).这是在AngularJS(版本1.5)中完成的方式:
function logout() {
//hide $mdDialog modal
angular.element('.md-dialog-container').hide();
//hide any open $mdDialog modals & backdrop
angular.element('.modal-dialog').hide();
angular.element('md-backdrop').remove();
//hide any open bootstrap modals & backdrop
angular.element('.inmodal').hide();
angular.element('.fade').remove();
//hide any sweet alert modals & backdrop
angular.element('.sweet-alert').hide();
angular.element('.sweet-overlay').remove();
}
Run Code Online (Sandbox Code Playgroud)
我怎么能在Angular中做到这一点?使用$('.mat-dialog-container')
或$('.inmodal')
不给我一个选择hide()
或做close()
我尝试过这样做,但我无法获得元素参考:
import { ElementRef, Injectable, ViewChild } from '@angular/core';
import { MatDialog, MatDialogContainer, MatDialogRef } from '@angular/material';
export class MyClass
{
@ViewChild('.mat-dialog-container') _matDialog: ElementRef;
@ViewChild('.mat-dialog-container') _matDialogRef:MatDialogRef<MatDialog>;
constructor() { }
function logout()
{
//access the …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下msdeploy命令部署我的应用程序:
MSDeploy.exe -source:contentPath="C:\Users\myUser\Documents\ui\dist" -dest:contentPath='c:/inetpub/wwwroot/dist',computerName="https://ec2-xx-xxx-xx-xx.ap-northeast-1.compute.amazonaws.com:8172/MSDeploy.axd?site=Default Web Site",username="administrator",password="XXXXXXXXX",authtype="Basic",includeAcls="False" -verb:sync -allowUntrusted
Run Code Online (Sandbox Code Playgroud)
收到以下错误:
Working...
Info: Using ID '01657062-cece-4713-8dc6-585537b265fd' for connections to the rem
ote server.
>> Error Code: ERROR_DESTINATION_NOT_REACHABLE
>> More Information: Could not connect to the remote computer ("ec2-52-207-222-6
5.compute-1.amazonaws.com"). On the remote computer, make sure that Web Deploy i
s installed and that the required process ("Web Management Service") is started.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION
_NOT_REACHABLE.
>> Error: Unable to connect to the remote server
>> Error: A connection attempt failed because …
Run Code Online (Sandbox Code Playgroud) 我有一个用于SQL Server DB的Visual Studio 2015数据库项目,我可以在其中进行模式比较/数据比较,并手动将项目签入GIT.我想自动完成这个完整的模式/数据比较过程,生成脚本并将其检入GIT.有可能吗?如果是这样的话?
也许我会做这样的事情?使用EnvDTE自动化Visual Studio
我正在尝试在sweet alert
类似于Bootstrap模态对话框(http://jsfiddle.net/D6rD6/5/)的对话框中显示微调框
我能想到的最接近的东西是这样的:
SweetAlert.swal({
title: '<small>Import errors occurred !</small>',
text: '<i class="fa fa-spinner" aria-hidden="true"></i>',
html: true,
customClass: 'manual-upload-errors-swal-width'
});
Run Code Online (Sandbox Code Playgroud)
如果这不可能,那么最近和最好的解决方案是什么?
javascript twitter-bootstrap angularjs bootstrap-modal sweetalert
当从控制器到我的node.js后端执行Restful调用时,我得到"ReferenceError:success is not defined",如下所示:
authControllers.js:
authControllers.controller('authCtrl', ['$scope', '$location', '$window', 'UserService', 'AuthenticationService',
function authCtrl($scope, $location, $window, UserService, AuthenticationService) {
$scope.me = function() {
UserService.me(function(res) {
$scope.myDetails = res;
}, function() {
console.log('Failed to fetch details');
$rootScope.error = 'Failed to fetch details';
})
};
}]);
Run Code Online (Sandbox Code Playgroud)
authServices.js:
authServices.factory('UserService',['$http', function($http) {
return {
me:function() {
return $http.get(options.api.base_url + '/me').success(success).error(error)
}
}
}]);
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="row" data-ng-controller="authCtrl" data-ng-init="me()">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<strong>Your Details</strong>
</div>
<div class="panel-body">
<p>{{myDetails.data.username}}</p>
<p>{{myDetails.data.email}}</p>
</div>
</div>
</div> …
Run Code Online (Sandbox Code Playgroud) 我有两个名为权重和值的数组。我想根据权重的排序对值进行排序。通过这样做,效果非常好
Array.Sort(Weights,Values);
Run Code Online (Sandbox Code Playgroud)
这给了我按升序排序的数组。我想按降序进行相同的排序。有没有更好的方法不使用
Array.Reverse(Weights) and Array.Reverse(Values)
我对 groovy 很陌生。在我Jenkinsfile
尝试将 windows cmd 输出存储在一个变量中,在下一个命令中使用它,但似乎没有任何效果。这是我得到的最接近的:
pipeline {
agent any
stages {
stage('package-windows') {
when {
expression { isUnix() == false}
}
steps {
script {
FILENAME = bat(label: 'Get file name', returnStdout: true, script:"dir \".\\archive\\%MY_FOLDER%\\www\\main.*.js\" /s /b")
}
bat label: 'replace content', script: "powershell -Command \"(gc \"$FILENAME\") -replace \"https://my-qa.domain.com/api/\", \"https://my-prod.domain.com/api/\" | Out-File \"$FILENAME\"\""
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我这样做ECHO "$FILENAME"
时,我得到的输出是:
C:\Program Files (x86)\Jenkins\workspace\my-ui>dir ".\archive\55131c0d3c28dc69ce39572eaf2f8585996d9108\main.*.js" /s /b
C:\Program Files (x86)\Jenkins\workspace\my-ui\archive\55131c0d3c28dc69ce39572eaf2f8585996d9108\www\main.16aedaf4c6be4e47266d.js
Run Code Online (Sandbox Code Playgroud)
我只需要main.16aedaf4c6be4e47266d.js
在下一个命令中使用的文件名来修改内容。但是在下一个命令中"$FILENAME"
是空的。如何将命令输出正确存储在变量中并在下一个命令中访问?
我们有一个基于 .NET 远程处理构建的 Windows 应用程序。它\xe2\x80\x99是使用.NET Framework 2.0构建的32位应用程序。我们使用 .NET Framework 4 的 SAP Crystal reports 运行时引擎(32 位 \xe2\x80\x93 版本 13.0.3)来实现报告功能。还有一个打印功能,可以在批处理运行期间将相应的报告打印到用户选择的打印机上。整个设置在 Windows Server 2003 服务器上运行良好。现在我们正在尝试将应用程序迁移到Windows Server 2008,但打印无法正常工作。它始终将报告打印到 Windows Server 2008 计算机上的默认打印机,而不是打印到所选打印机。
\n\nCrystalDecisions.CrystalReports.Engine、CrystalDecisions.ReportSource 和 CrystalDecisions.Shared 是引用自的 DLL\xe2\x80\x99s
\n\nC:\\Program Files\\sap Businessobjects\\crystal reports for .net Framework 4.0\\common\\sap Businessobjects enterprise xi 4.0\\win32_x86
\n\n我们将应用程序转换为 64 位版本。在 Windows Server 2008 上,即使我们安装了 .NET Framework 4 的 SAP Crystal reports 运行时引擎(64 位 \xe2\x80\x93 版本 13.0.3),打印也无法正常工作(始终打印到默认打印机) )。在64位安装文件夹中也找不到\xe2\x80\x99s上述DLL\xe2\x80\x99s。
\n\nC:\\Program Files\\sap Businessobjects\\crystal reports for .net Framework 4.0\\common\\sap Businessobjects enterprise …
我正在尝试使用C#
代码从 Vault(Vault 2015 SDK)下载文件。尝试了与此处提到的完全相同的方法:http :
//inventorhub.autodesk.com/discussions/threads/301/post/5600165
但得到错误
在执行用于下载文件的相应代码行时,请求失败,HTTP 状态为 404:未找到”。
请在下面找到我的示例代码:
using Autodesk.Connectivity.WebServicesTools;
using Autodesk.Connectivity.WebServices;
UserPasswordCredentials login = new UserPasswordCredentials("servername", "myVault", "username", "Password", true);
using (WebServiceManager serviceManager = new WebServiceManager(login))
{
Autodesk.Connectivity.WebServices.Folder folder = serviceManager.DocumentService.GetFolderByPath("$/Myfolder");
Autodesk.Connectivity.WebServices.File[] files = serviceManager.DocumentService.GetLatestFilesByFolderId(folder.Id, false);
if (files != null && files.Any())
{
foreach (Autodesk.Connectivity.WebServices.File file in files)
{
//Sample code to download the files
string localPath = AppDomain.CurrentDomain.BaseDirectory;
Autodesk.Connectivity.WebServices.File localFile = serviceManager.DocumentService.GetFileById(file.Id);
var FileDownloadTicket = serviceManager.DocumentService.GetDownloadTicketsByFileIds(new long[] { file.Id });
FilestoreService fileStoreService …
Run Code Online (Sandbox Code Playgroud) 运行节点服务器时出现以下错误:
$ node server.js
module.js:339
throw err;
^
Error: Cannot find module './server/routes'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (C:\Users\attas\documents\github\angular-express-auth\server.js:12:10)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
Run Code Online (Sandbox Code Playgroud)
以下是我的项目结构:
server.js:
var express = require('express'),
jwt = require('express-jwt'),
bodyParser = require('body-parser'),
morgan = require('morgan'),
methodOverride = require('method-override'),
errorHandler = require('express-error-handler'),
tokenManager = require('./server/config/token_manager'),
secret = require('./server/config/secret'),
http = require('http'),
path = require('path');
var app = module.exports …
Run Code Online (Sandbox Code Playgroud) javascript ×4
angularjs ×3
c# ×3
node.js ×2
.net ×1
angular ×1
arrays ×1
autodesk ×1
cmd ×1
jwt ×1
msdeploy ×1
ng-bootstrap ×1
npm ×1
printing ×1
sorting ×1
sweetalert ×1
sweetalert2 ×1
windows ×1