我有一个 angular 组件,它将一些数据发布到我们应用程序中的 URL,然后什么都不做,因为没有数据从该帖子返回。我在测试这个时遇到了麻烦,因为通常 HTTP 请求是通过订阅它们返回的 observable 来测试的。在这种情况下不需要暴露。
这是我的组件代码:
shareData(): void {
this.isFinishing = true;
this.myService.sendSharedData$()
.pipe(first())
.subscribe(() => {
//Data s now shared, send the request to finish up everything
this.submitFinishRequest();
}, (e: Error) => this.handleError(e)));
}
private submitFinishRequest(): void {
//submit data to the MVC controller to validate everything,
const data = new FormData();
data.append('ApiToken', this.authService.apiToken);
data.append('OrderId', this.authService.orderId);
this.http.post<void>('/finish', data)
.pipe(first())
.subscribe((d) => {
// The controller should now redirect the app to the logged-out MVC view, so …
Run Code Online (Sandbox Code Playgroud) 我有一些基本代码可以循环从Adobe RoboHelp生成的一些XML(我们的帮助文档).这样可以正常工作,但由于主题可以按照编写者的需要嵌套很多时间,因此我需要一种更好的方法来遍历此XML而不仅仅是嵌套.each()
循环.
这是XML的样子
<?xml version="1.0" encoding="utf-8"?>
<!--RoboML: Table of Content-->
<roboml_toc>
<page title="Welcome" url="Welcome.htm"/>
<book title="Getting Started" url="Getting_Started/Initial_Setup.htm">
<page title="Initial Setup" url="Getting_Started/Initial_Setup.htm"/>
<page title="Customize Settings" url="Getting_Started/Settings.htm"/>
</book>
<book title="Administrator Services" url="Administrator_Services/General_Administrator.htm">
<book title="Portal Workspace" url="Administrator_Services/Portal_Workspace/AdminHome.htm">
<page title="Home" url="Administrator_Services/Portal_Workspace/AdminHome.htm"/>
<page title="Portal Accounts" url="Administrator_Services/Portal_Workspace/Portal_Accounts.htm"/>
</book>
<book title="SpamLab" url="Administrator_Services/SpamLab/SpamLab_Admin_General.htm">
<page title="Alerts" url="Administrator_Services/SpamLab/Alerts.htm"/>
<page title="Spam Quarantine" url="Administrator_Services/SpamLab/Admin_Spam_Quarantine_.htm"/>
</book>
</book>
<book title="User Services" url="User_Services/General_User.htm">
<book title="Portal Workspace" url="User_Services/Portal_Workspace/Home.htm">
<page title="Home" url="User_Services/Portal_Workspace/Home.htm"/>
<page title="Self Help" url="User_Services/Portal_Workspace/Self_Help.htm"/>
</book>
<book title="SpamLab" url="User_Services/SpamLab/SpamLab_General.htm">
<page title="Spam Quarantine" url="User_Services/SpamLab/Spam_Quarantine.htm"/> …
Run Code Online (Sandbox Code Playgroud) 我有一个免费的文本表格供人们提交反馈/支持请求.有时,人们会在支持票据或错误日志中过去,该日志包含触发.NET页面验证程序作为XSS尝试的内容.这会将用户带到错误页面,就好像该站点在其输入上被阻塞一样.
最好是,当我们在实际提交之前按下保存按钮时,我宁愿让页面进行一些客户端验证.
是否有一个正则表达式或一些方法我可以在客户端进行相同的基本检查,或者我只需要编写一个不允许某些字符一起使用的正则表达式<
和>
?
检查屏幕截图.您会注意到具有焦点的复选框实际上与其他复选框的呈现方式不同.什么会让它在IE9中出现?
我有以下CSS片段,我只注意到如果我删除以下所有CSS这个问题不再发生.但是,如果我只删除这些规则中的任何一个或两个,它仍然会发生.我很困惑.
textarea:active,
textarea:focus,
textarea:active:hover,
textarea:focus:hover,
select:active,
select:focus,
select:active:hover,
select:focus:hover,
input:active,
input:focus,
input:active:hover,
input:focus:hover{
background-color:#f9f9f5;
border-color:#658cae;
-webkit-box-shadow:inset 0 1px 2px #b8b7b3, 0 0 8px #7899b5;
-moz-box-shadow:inset 0 1px 2px #b8b7b3, 0 0 8px #7899b5;
box-shadow:inset 0 1px 2px #b8b7b3, 0 0 8px #7899b5;
z-index:1;/* for Opera */
}
input[type="file"]:focus,
input[type="file"]:active,
input[type="radio"]:focus,
input[type="radio"]:active,
input[type="checkbox"]:focus,
input[type="checkbox"]:active {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
input[type="file"]:focus,
input[type="file"]:active,
input[type="file"][disabled],
input[type="radio"]:focus,
input[type="radio"]:active,
input[type="radio"][disabled],
input[type="checkbox"]:focus,
input[type="checkbox"]:active,
input[type="checkbox"][disabled]{
background-color:transparent;
}
Run Code Online (Sandbox Code Playgroud)
这是一个现场演示:http://jsfiddle.net/QRzRw/1/
我创建了一系列各种脚本文件,我希望将它们组合在一起/缩小.在隐藏文件我的代码(是的,对不起,这是在VB!)我将它添加到<asp:placeholder />
在<head>
这样的
Me.PlhHeader.Controls.Add(New LiteralControl(Scripts.Render("~/bundles/main").ToHtmlString()))
Run Code Online (Sandbox Code Playgroud)
这将起作用,但它似乎总是输出压缩的缩小版本,即使debug="true"
在Web.Config中也是如此.
无论如何,这就是输出: <script src="/bundles/main"></script>
在调试模式下,我需要做些什么来使这个输出成为单独的未压缩文件?
编辑
我还尝试手动设置选项BundleTable.EnableOptimizations = false
,它仍然输出单个缩小的脚本标记.我没有想法.
我用一些相关的代码做了一些非常愚蠢的事情,但从技术上讲,捆绑的一切都很好并且工作正常.问题解决了我!
我需要通过给它一个ID选择器来选择一系列HTML.我下面的内容在Chrome和Firefox中效果很好,但在IE 10(标准模式)中却没有.(IE的旧版本不是这个问题)
function selectElementContents(elementId) {
var elemToSelect = document.getElementById(elementId);
var selection= window.getSelection();
var rangeToSelect = document.createRange();
rangeToSelect.selectNodeContents(elemToSelect);
//console.log(rangeToSelect);
selection.removeAllRanges();
selection.addRange(rangeToSelect);
}
Run Code Online (Sandbox Code Playgroud)
奇怪的是,该行将console.log(rangeToSelect)
绝对记录IE 10中的正确文本,但它不会选择它.
我有一个很长的页面,用Angular构建.页面上的图像是延迟加载的,因此src
在图像滚动到视图之前不会设置.
容器是灵活的,图像的尺寸永远不应大于它们的尺寸(我知道并且可以在style
属性上设置)
现在我在没有设置源的情况下正确缩放图像时遇到问题.
TL; DR
我想要<img src='pic.jpg'/>
并且<img src=''/>
在最大尺寸的柔性容器内占据相同数量的空间.
演示:http://codepen.io/chrismbarr/pen/xGgGRq? edit = 110
HTML(这将从JavaScript生成,我们提前了解维度)
<div class="container" style='max-width: 500px; max-height: 700px;'>
Image with a source
<img src="http://lorempixel.com/500/700/cats/2/" />
</div>
<div class="container" style='max-width: 500px; max-height: 700px;'>
Image with no source
<img src="" />
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
img{
display:block;
max-width: 100%;
}
img[src=''],
img:not([src]){
//no image source
height: 100%;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
这是一个难以设置图像尺寸的演示,因此它们不再灵活.这是我想要避免的:http://codepen.io/chrismbarr/pen/JdEYMe
我正在研究我们的 ASP.NET WebForms 项目,并尝试进行YSlow等工具建议的更改。我们对添加到项目中的文件使用 .NET 4.0 附带的内置捆绑和缩小,但仍有一些 JavaScript 文件被 WebForms 框架包含在未缩小的范围内:ScriptResource.axd
和WebResource.axd
我环顾四周,找到了很多关于如何缩小这些文件的 3rd 方解决方案,但是所有这些解决方案在框架中内置 JS 压缩器之前已经有几年的历史了。现在它是内置的,似乎应该可以以某种方式利用它。
我怎样才能让这些*.axd
文件有一个缩小的输出?
javascript asp.net webforms minify bundling-and-minification
我们使用功能标记(在Web.Config中设置)来切换UI中某些尚未完成的功能的可见性.我还希望我的MVC包不包含相关的JS文件,因为它们只是在没有启用该功能时客户端必须下载的无用文件.
到目前为止,我已经找到了,IgnoreList.Ignore
但我似乎无法让它工作.这基本上就是我在做的事情:
public static void RegisterBundles(BundleCollection bundles)
{
if (!appConfiguration.FeatureXEnabled)
{
//Skip these files if the Feature X is not enabled!
//When this flag is removed, these lines can be deleted and the files will be included like normal
bundles.IgnoreList.Ignore("~/App/Organization/SomeCtrl.js", OptimizationMode.Always);
bundles.IgnoreList.Ignore("~/App/Filters/SomeFilter.js", OptimizationMode.Always);
}
var globalBundle = new ScriptBundle("~/bundles/app-global").Include(
"~/App/RootCtrl.js",
"~/App/Directives/*.js",
"~/App/Services/*.js",
"~/App/Application.js"
);
bundles.Add(globalBundle);
var appOrgBundle = new ScriptBundle("~/bundles/app-org");
appOrgBundle.Include(
"~/App/Filters/*.js",
"~/App/Organization/*.js"
);
bundles.Add(appOrgBundle);
}
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,仍然包含忽略列表中的文件!我在这做错了什么?
我正在使用 Angular 4.1.3 版本并使用打字 1.4.0 版本。在执行 npm install 时,它会抛出以下错误。这从昨天开始就起作用了。从早上开始就出现这个问题。任何帮助,将不胜感激。
打字错误!消息无法连接到“https://api.typings.org/entries/dt/jasmine/tags/2.2.0%2B20160621224255”打字错误!证书过期导致的
打字错误!消息无法连接到“https://api.typings.org/entries/dt/core-js/tags/0.0.0%2B20160725163759”打字错误!证书过期导致的
我有 Typings.json 和以下条目
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160725163759",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160909174046"
}
Run Code Online (Sandbox Code Playgroud)
我按照以下步骤操作,但没有成功。
asp.net ×3
angular ×2
css ×2
javascript ×2
webforms ×2
.net ×1
angular-test ×1
asp.net-mvc ×1
c# ×1
checkbox ×1
html ×1
jquery ×1
loops ×1
minify ×1
node-modules ×1
node.js ×1
npm ×1
regex ×1
robohelp ×1
validation ×1
vb.net ×1
xml ×1