我想创建一个通用的html片段组件.我们的想法是将html片段存储在db中的某个地方,以及应该应用于它们的样式.
我可以轻松设置innerHtml以将html结构插入到我的视图模板中的基本元素中,但是如何在我的视图模板中动态插入<style>标记?
这就是我所拥有的:
@Component({
moduleId: module.id,
selector: 'htmlFragment',
styleUrls: ['html-fragment.css'],
templateUrl:'html-fragment.html'
})
export class HtmlFragmentComponent {
@Input() htmlContent: string;
@Input() styleContent: string;
}
Run Code Online (Sandbox Code Playgroud)
这是视图模板:
<style [innerHTML]="styleContent"></style>
<div [innerHTML]="htmlContent"></div>
Run Code Online (Sandbox Code Playgroud)
然后我试着像这样使用它:
<htmlFragment [htmlContent]='dHtml' [styleContent]="sHtml"></htmlFragment>
Run Code Online (Sandbox Code Playgroud)
哪里:
dHtml: string = '<div>hello this is html<ul><li>bla bla</li><li>bla bla 2</li></ul></div>';
sHtml: string = 'ul{list-style-type: none;}';
Run Code Online (Sandbox Code Playgroud)
html片段在这里正确注入:
<div [innerHTML]="htmlContent"></div>
Run Code Online (Sandbox Code Playgroud)
但是这里的样式元素:
<style [innerHTML]="styleContent"></style>
Run Code Online (Sandbox Code Playgroud)
工作不对.有没有办法做到这一点?
我开始接触角6位,并且对Angular Elements和新的库项目非常感兴趣。我有一个即将到来的项目,可能需要这两个新功能。
我需要创建可在Web框架之间重用的自定义UI组件,但我还希望获得在角项目中使用它们的一流支持。我已按照本教程进行操作,并拥有一个angular6应用程序,该应用程序注册自定义元素,并将webpack捆绑包合并到一个文件中。然后,我可以在纯HTML页面中使用该单个js文件,并且一切正常。
关键是在库项目中创建这些自定义元素会很棒。这样,我可以在内部npm注册表中分发我的库,以及构建包含所有自定义元素的js并将其部署在CDN上。
是否可以在新的库项目中构建Angular Elements?
我觉得自己像个白痴,但是我不能让这个SP默认为一个值....这就是我如何宣布我的参数.
ALTER PROCEDURE [dbo].[PCS_DocumentCacheInsert]
(
@sessionId varchar(200),
@mrn varchar(50) ,
@fromDate datetime,
@toDate datetime,
@aggregate varchar(50),
@author varchar(50),
@datePerformed dateTime,
@docId varchar(15),
@encounterId varchar(15),
@facility varchar(5),
@level char(1),
@orderedByAuthor varchar(50),
@resultAuthor varchar(50),
@resultCode varchar(5),
@resultId varchar(30),
@resultName varchar(30),
@status varchar(5),
@subType varchar(10),
@type varchar(10),
@security varchar(3),
@serviceGroup varchar(15),
@witmurNum varchar(10),
@deptId varchar(10),
@deptText varchar(40),
@cacheCreateTS dateTime ,
@cacheStatus varchar(8) ='notReady',
@cacheUpdateTS datetime
)
Run Code Online (Sandbox Code Playgroud)
这个过程一切正常,除了我无法达到notReady默认值@cacheStatus.谷歌说我正在使用正确的语法.
这是我在MS中打电话的方式
EXEC @return_value = [dbo].[PCS_DocumentCacheInsert]
@sessionId = N'asdfssa',
@mrn = N'asdf',
@fromDate …Run Code Online (Sandbox Code Playgroud) 现代化器可以检测浏览器是否安装并启用了pdf插件?我在Web应用程序的iframe中显示pdf.当pdf插件不存在时,我从dom客户端删除iframe.我正在使用一些笨重的javascript来进行检测,并希望用更强大/标准的东西替换它并遇到了modernizr.任何人都知道这是否可行?
我刚升级到angular2最终版本,rc4有很多重大变化.其中一个是组件上不再有Directives集合......我想做这样的事情:
@Component({
selector: 'resource-tab',
templateUrl: './app/applicationMgmt/resource/resource-tab.html',
directives: [
NgSwitch,
NgSwitchCase,
NgSwitchDefault,
OtherResourceEditorComponent,
MvcResourceEditorComponent,
WcfResourceEditorComponent,
WebResourceEditorComponent,
WebApiResourceEditorComponent,
ConfigResourceEditorComponent
]
})
Run Code Online (Sandbox Code Playgroud)
引用在视图模板上用作指令的其他组件...现在如何做到这一点?
我正在尝试做一些听起来很简单的事情,但我找不到任何满足我需求的例子.我有一个简单的组件,呈现ajax微调器,但我想允许使用者传入一个类或多个类(由空格分隔)作为组件的输入参数,并让组件视图模板将类添加到img标记中模板.这是我的组件:
import { Component, OnInit, Input } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'loading',
templateUrl: 'loading.html',
inputs: ['imgClass']
})
export class LoadingComponent {
@Input() imgClass: string;
}
Run Code Online (Sandbox Code Playgroud)
这是视图模板:
<img [ngClass]="{ imgClass : true}" src="./Content/img/loading_spinner.gif" />
Run Code Online (Sandbox Code Playgroud)
这是我想要使用它的方式:
<div class="row" *ngIf="isLoading">
<div class="col-xs-4"></div>
<div class="col-xs-4 no-pad"><loading [imgClass]="center-block"></loading></div>
<div class="col-xs-4"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
所以我想通过加载组件将中心块添加到img标签,但它似乎没有工作.
它没有获得imgClass变量值,而是将文字'imgClass'添加为类.
我正在构建一个Angular2应用程序,并且有两个BehaviourSubjects我想在逻辑上组合成一个订阅.我正在制作两个http请求,并希望在两个人都回来时发起一个事件.我期待在forkJoinVS combineLatest.似乎当更新behvaviorSubjects时,combineLatest将会触发,而forkJoin只会在所有behavoirSubjects更新后触发.它是否正确?必须有一个普遍接受的模式,这不是吗?
编辑
这是我的angular2组件订阅的一个behaviorSubjects的示例:
export class CpmService {
public cpmSubject: BehaviorSubject<Cpm[]>;
constructor(private _http: Http) {
this.cpmSubject = new BehaviorSubject<Cpm[]>(new Array<Cpm>());
}
getCpm(id: number): void {
let params: URLSearchParams = new URLSearchParams();
params.set('Id', id.toString());
this._http.get('a/Url/Here', { search: params })
.map(response => <Cpm>response.json())
.subscribe(_cpm => {
this.cpmSubject.subscribe(cpmList => {
//double check we dont already have the cpm in the observable, if we dont have it, push it and call next to propigate new cpmlist everywheres
if (! …Run Code Online (Sandbox Code Playgroud) 我正在寻找构建一些工具来查询团队冲刺的当前工作项目。我不确定如何在给定组织、项目和团队的情况下做到这一点。我似乎可以通过拨打此电话来获取当前迭代:
https://dev.azure.com/ {org}/{project}/{{team}/_apis/work/teamsettings/iterations?$timeframe=current&api-version=5.1
它返回类似这样的内容:
{
"count": 1,
"value": [
{
"id": "8c15e886-ece7-49ce-ab5a-4090aefb5ce2",
"name": "Sprint 1",
"path": "Red Kitten Matrix\\Sprint 1",
"attributes": {
"startDate": null,
"finishDate": null,
"timeFrame": "current"
},
"url": "https://dev.azure.com/chrisdevopsprojects/e8d05711-3014-4ba7-82b7-ab6829c455dc/aed68f47-9035-4af5-9b0d-b0c19b4e9e9e/_apis/work/teamsettings/iterations/8c15e886-ece7-49ce-ab5a-4090aefb5ce2"
}
]
}
Run Code Online (Sandbox Code Playgroud)
因此,我可以获得当前团队冲刺的指针,但是如何返回其中的所有冲刺工作项和任务?
我在这里没有看到任何信息:
谢谢!
编辑:
因此,我找到了一种工作项查询语言(WIQL...为什么不猜测)查询,当我在 UI 中的 DevOps 中调用它时,它可以工作,并且可以通过其余 API 进行工作,但它会让我做一个一堆 ajax 请求将所有内容拉回来。请告诉我是否有更简单的方法来获得这个。
这是我的 WIQL:
SELECT
[System.Id],
[System.WorkItemType],
[System.Title],
[System.AssignedTo],
[System.State],
[System.Tags]
FROM workitemLinks
WHERE
(
[Source].[System.TeamProject] = @project
AND [Source].[System.WorkItemType] <> 'Task'
AND [Source].[System.State] <> ''
AND [Source].[System.IterationPath] = @currentIteration('[Red Kitten Matrix]\Red Kitten Matrix …Run Code Online (Sandbox Code Playgroud) 我必须维护一些不再与公司合作的其他人编写的代码.我看到几个引用java.lang.reflect.Array.getLength(anArray).它工作,但我从来没有看到反射用于获得数组长度.有谁知道之间的区别:
java.lang.reflect.Array.getLength(anArray)
和
anArray.length
它只是语法糖吗?
谢谢!
在我的公司,我们还不能进入 .net core。我正在尝试研究如何最好地使用 azure 密钥保管库来存储我们的 api 应用程序服务的配置项。
我有一个带有 global.asax 文件的简单 webapi 项目:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.WebHost;
using System.Web.Routing;
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureKeyVault;
namespace kv.api
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
LoadAzureKeyVaultSettings();
}
protected void LoadAzureKeyVaultSettings()
{
var tokenProvider = new AzureServiceTokenProvider("RunAs=CurrentUser;");
var kvClient = new KeyVaultClient((authority, resource, scope) => tokenProvider.KeyVaultTokenCallback(authority, resource, scope));
var builder = new ConfigurationBuilder()
.AddAzureKeyVault("https://mykvurihere.vault.azure.net/", kvClient, new DefaultKeyVaultSecretManager());
builder.Build(); …Run Code Online (Sandbox Code Playgroud) 如果给定字段为空,太短或太长,我试图隐藏/显示相应的错误消息.这是我表格的一部分:
<form #applicationForm="ngForm" (ngSubmit)="saveApplication()" class="form-horizontal">
<div class="row-fluid">
<div [class.has-error]="name.touched && name.errors" class="form-group">
<label for="name" class="col-sm-2 control-label form-lbl">Name</label>
<div class="col-sm-10">
<input type="text"
class="form-control" placeholder="Name"
minlength="8" maxlength="200" required
[(ngModel)]="application.Name" ngControl="name" #name="ngForm">
<p *ngIf="name.errors.minlength" class="help-block">Name is too short, it must be at least 8 characters.</p>
<p *ngIf="name.errors.maxlength" class="help-block">Name is too long, it must be less than 200 characters.</p>
<p *ngIf="name.errors.required" class="help-block">Name is required.</p>
</div>
</div>
</div>...
Run Code Online (Sandbox Code Playgroud)
如果我在段落标签中注释掉*ngIf,那么表单起作用,否则我得到一个js错误"TypeError:无法读取属性'minlength'的null"
这让我觉得错误集合是空的,我如何得到具体的错误?
作为参考我正在使用: Deborah Kurata - ng-conf
@peppermcknight推荐的解决方案有效.在ngIf中添加以下检查解决了问题:
<p *ngIf="applicationForm.dirty && name.errors.minlength" class="help-block">Name is too short, it …Run Code Online (Sandbox Code Playgroud) 我一直在为此苦苦挣扎,所以我会选择 SO。
我有一个应用程序,需要将字符串解析为日期时间。字符串如下所示:
"201503131557"
Run Code Online (Sandbox Code Playgroud)
(它们将始终采用“yyyyMMddHHmm”这种格式)并且始终采用中部标准时间(或中部夏令时,具体取决于日期),即使它们没有指定。
当我解析它们时,我明白它会将它们解析为本地时间。我在 Azure PaaS 上运行,并且不想为了支持此操作而将其更改为在 CST 中运行。
我如何编写同时在本地和 Azure PaaS 中运行的代码,以便将这些日期正确解析为 DateTimes 并将其时区设置为 CST?
这是我为证明 Matt Johnson 的答案而编写的快速单元测试。
[TestMethod]
public void DateTests()
{
var unSpecDt = DateTime.ParseExact("201503131557", "yyyyMMddHHmm", CultureInfo.InvariantCulture);
var tz = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
var utcDt = TimeZoneInfo.ConvertTimeToUtc(unSpecDt, tz);
var offset = tz.GetUtcOffset(unSpecDt);
var dto =new DateTimeOffset(unSpecDt, offset);
var cstDt = dto.DateTime;
Assert.IsTrue(cstDt.Hour - utcDt.Hour == offset.Hours);
}
Run Code Online (Sandbox Code Playgroud) 我有一个jquery选择器,我想改变,以便它不会选择<div id="divA"></div>.
继承当前的选择器:
$('ul.toggle a').on('click', function () {
//does some work
});
Run Code Online (Sandbox Code Playgroud)
我试过$('ul.toggle a [id!=divA]')但是错了.
这个选择器的预期格式是什么?
angular ×5
angular6 ×1
arrays ×1
azure ×1
azure-devops ×1
c# ×1
datetime ×1
forms ×1
java ×1
javascript ×1
jquery ×1
modernizr ×1
pdf ×1
reflection ×1
rxjs ×1
sql-server ×1
timezone ×1