我创建了一个使用marked包来呈现markdown内容的组件,当异步事件更改其ng-content元素时,它不会重新呈现自身.
这是代码
import {Component, ElementRef, AfterContentInit} from 'angular2/core';
declare var marked: any;
@Component({
selector: 'markdown',
template:
'<div style="display:none;">' +
' <ng-content></ng-content>' +
'</div>' +
'<div class="markdown" [innerHTML]="output"></div>'
})
export class MarkdownComponent implements AfterContentInit {
output: string;
constructor(
private element: ElementRef) {
}
ngAfterContentInit() {
const c = this.element.nativeElement.childNodes;
this.output = marked(c[0].textContent);
}
}
Run Code Online (Sandbox Code Playgroud)
这是HTML片段:
<markdown>{{info}}</markdown>
Run Code Online (Sandbox Code Playgroud)
这是异步更新:
updateInfo(text: string) {
this.svc.update(this.info, text).subscribe(
data => this.info = data.newText);
}
Run Code Online (Sandbox Code Playgroud)
问题是,当this.svc.update事件触发时,info变量会更改值,但markdown组件不会重新呈现.
谢谢!
解析度 …
我似乎无法找到一种直接的方法来实现将文本输入过滤到WPF组合框中的项目列表中.
通过将IsTextSearchEnabled设置为true,comboBox下拉列表将跳转到第一个匹配项目的任何内容.我需要的是将列表过滤到与文本字符串匹配的任何内容(例如,如果我专注于我的组合框并键入'abc',我希望看到ItemsSource集合中的所有项目以(或最好包含)开头)'abc'作为下拉列表的成员).
我怀疑它有所不同,但我的显示项目模板化为复杂类型的属性:
<ComboBox x:Name="DiagnosisComboBox" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3"
ItemsSource="{Binding Path = ApacheDxList,
UpdateSourceTrigger=PropertyChanged,
Mode=OneWay}"
IsTextSearchEnabled="True"
ItemTemplate="{StaticResource DxDescriptionTemplate}"
SelectedValue="{Binding Path = SelectedEncounterDetails.Diagnosis,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"/>
Run Code Online (Sandbox Code Playgroud)
谢谢.
我们需要在WinForms应用程序中的控件上执行以下操作。
public class BindableDataItem
{
public bool Visible {get; set; }
public bool Enabled {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
现在我们想将BindableDataItem绑定到文本框。
这里是绑定关联。
TextBox.Enabled <==> BindableDataItem.Enabled
TextBox.Visible <==> BindableDataItem.Visible
现在,一个BindableDataItem对象可以与许多具有不同类型的控件关联。
通过调用(BindableDataItem)obj.Enabled = false,应禁用附加到BindableDataItem对象的所有控件。
任何帮助将不胜感激。
当在表单组上使用带有异步验证器的反应式表单时,如果通过patchValue在构造函数或 in 中使用来更改表单组的值ngOnInit- 即使异步验证器可观察完成,表单仍保持PENDING状态。
在示例中,您会看到一个包含两个字段的简单表单,其中指示表单状态和验证器状态。在代码中,ngOnInit我调用patchValue表单,导致表单进入PENDING状态,并调用异步验证器。
异步验证器没有做太多事情,它只是等待 1 秒,然后返回一个null错误对象,基本上表明表单是有效的。您可以在指示中看到验证已完成,但表单仍保持PENDING状态。
ngOnInit如果您在构造函数或对象构造之外的任何时间触发字段值的更改,那么VALID当验证程序完成时,表单会进入状态。如果您将值更改包装在 中,这也适用setTimeout。
难道我做错了什么?这是正常行为,还是 Angular 中的错误?
我试图创建一个简单的网格视图绑定到一个简单的xml文档,但我必须丢失一些东西,因为我一直收到错误消息:
ID为'GridView1'的GridView的数据源没有任何属性或属性可用于生成列.确保您的数据源包含内容.
码
<asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1">
<Columns>
<asp:BoundField DataField="id" HeaderText="ID" SortExpression="id" />
</Columns>
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="Notifications.xml" XPath="/data/node"></asp:XmlDataSource>
Run Code Online (Sandbox Code Playgroud)
XML
<?xml version="1.0" encoding="utf-8" ?>
<data>
<node>
<id>1096</id>
<name>About Us</name>
<date>21/12/2009 17:03:43</date>
<user id="1">writer</user>
</node>
<node>
<id>1099</id>
<name>News</name>
<date>21/12/2009 17:03:47</date>
<user id="1">writer</user>
</node>
<node>
<id>1098</id>
<name>Another page</name>
<date>21/12/2009 17:03:52</date>
<user id="1">writer</user>
</node>
</data>
Run Code Online (Sandbox Code Playgroud)
是不是我的xpath错了,或者我在这里犯了一些根本错误的东西?
我尝试在我的WPF应用程序中使用LINQ to SQL向SQLServer db表添加记录,但总是会收到有关缺少指令的错误.通常intellisense会对这个问题给出一个暗示,但这次不是.这里我的代码包含所有指令:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
...
...
DateTime newdate = new DateTime(2010, 2, 1);
TimeSpan newtime = new TimeSpan(12, 00, 00);
MyfirstdbDataContext context = new MyfirstdbDataContext();
Meeting meeting = new Meeting();
meeting.MeetID = "01.02.10_12:00";
meeting.Date = newdate;
meeting.Time = newtime;
context.Meetings.Add(meeting); // Here I get the debugger error
context.SubmitChanges();
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
System.Data.Linq.Table'不包含'Add'的定义,也没有扩展方法'Add'接受类型为'System.Data.Linq.Table'的第一个参数'(你是否缺少using指令或装配参考?)
请问,我的代码有什么问题?
我正在尝试使用fslex和编写一个小型 DSL 解析器fsyacc。输入由需要不同词法规则的两种不同语言的交错块组成。我如何编写我的fslex文件来支持它?
(我想类似的情况是如何fslex为 c 语言定义文件但支持内联汇编,这需要不同的词法分析规则?)
我目前拥有的是这样的:
rule tokenize = parse
| "core" { core lexbuf }
...
and core = parse
| ...
Run Code Online (Sandbox Code Playgroud)
问题是,一旦core解析器返回一个令牌,输入的下一部分就会被传递给tokenize。但是,我想(原样)留在该core州。我怎么做?
谢谢!
我有一个复杂的场景,我需要帮助.
我有一个指令(称为TagDirective),它放在我的应用程序的多个元素上.我有另一个指令(QueryDirective),它需要引用TagDirective其主机元素上存在的所有实例,以及层次结构中它上面的所有元素.
例:
<div appTag="a">
<div appTag="b">
<div appTag="c">
<div appTag="d">
<div appQuery>
<!-- In here I want to have a reference to TagDirectives instances
d,c,b,a -->
</div>
</div>
</div>
<div appTag="e">
<div appTag="f">
<div appTag="g">
<div appTag="h">
<div appQuery>
<!-- In here I want to have a reference to TagDirectives instances
h,g,f,e,b,a -->
</div>
</div>
</div>
<div appQuery>
<!-- In here I want to have a reference to TagDirectives instances
f,e,b,a -->
</div> …Run Code Online (Sandbox Code Playgroud) 我的数据模型:
export class Contact {
constructor(
public type: ContactTypes,
public name: string,
public link?: string
) {
}
}
export enum ContactTypes {
Address = 'address-card-o',
Phone = 'phone',
Mobile = 'mobile',
Email = 'envelope-o',
FaceBook = 'facebook',
Viber = 'viber',
Instagram = 'instagram',
Skype = 'skype',
Linkedin = 'linkedin',
VK = 'vk',
Youtube = 'youtube-play',
Messanger = 'messanger',
}
Run Code Online (Sandbox Code Playgroud)
迭代模型集合我需要根据其类型绘制图标。有些图标可以按通常的方式被淹没,其他图标则需要特殊的规则。所以我准备了一些templates:
<ng-template #viber>
<p>viber icon is drawn</p>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
<ng-template #icon let-type="type">
<p>{{type}} icon is drawn</p>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
这些模板由 Looped …
我在 Wpf 中使用数据表绑定了我的 DataGrid。但是我看不到任何数据。我可以看到在 UI 的网格中创建了三行,但数据不可见。我也尝试更改前景色和背景色。我不知道为什么会这样。
任何帮助将是可观的。
我的代码
背后的代码
我试过这种方式
dt.AsEnumerable().ToList().ForEach(i => dgvSummary.Items.Add(i));
Run Code Online (Sandbox Code Playgroud)
并且
dgvSummary.ItemsSource = dt.AsEnumerable().ToList();
Run Code Online (Sandbox Code Playgroud)
XAML 文件
<my:DataGrid xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"
Name="dgvSummary" ItemsSource="{Binding}" Grid.Row="1"
MinWidth="520" Height="180" HorizontalAlignment="Left"
FontSize="10" Background="#FFFEEFC8"
AutoGenerateColumns="False" SelectionUnit="Cell"
SelectionMode="Single" RowBackground="Transparent">
<my:DataGrid.Columns>
<my:DataGridTemplateColumn Header="First Name"
IsReadOnly="True">
<my:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Visibility="Visible"
Foreground="Red"
Background="Transparent"
Text="{Binding Path=First_Name}"/>
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
<my:DataGridTemplateColumn Header="Last Name"
IsReadOnly="True">
<my:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Foreground="Black"
Text="{Binding Path=LAST_NAME}"/>
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
</my:DataGrid.Columns>
</my:DataGrid>
Run Code Online (Sandbox Code Playgroud) 我有一个带有路由和解析防护的 Angular 应用程序。解析守卫是异步的,并返回一个从返回的可观察量HttpClient.post- 问题是,AJAX 请求完成但可观察量没有完成,因此解析器永远不会完成其工作,并且页面永远不会显示。然而,当我通过管道传输结果时,take(1)它确实完成并且工作正常。我的问题是为什么?HttpClient.postAJAX 请求返回 ok ( ) 后不应该完成吗200 OK?
这是我的解析器的代码:
@Injectable()
export class MyDataResolver implements Resolve<MyData> {
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot)
: MyData | Observable<MyData> | Promise<MyData> {
return this.svc.getData().pipe(take(1)); // <-- Why is take(1) necessary here??
}
constructor(private svc: MyService) { }
}
Run Code Online (Sandbox Code Playgroud)
这是调用的服务方法post:
import { HttpClient } from '@angular/common/http';
export class MyService {
constructor(private http: HttpClient) {}
getData(): Observable<MyData> {
return this.http.post('/api/data'), {}).pipe(
map((resp: { data: …Run Code Online (Sandbox Code Playgroud) angular ×5
c# ×4
data-binding ×2
wpf ×2
.net ×1
angular6 ×1
asp.net ×1
combobox ×1
datagrid ×1
f# ×1
fslex ×1
gridview ×1
linq ×1
linq-to-sql ×1
ng-container ×1
ng-content ×1
ng-template ×1
parameters ×1
winforms ×1
xml ×1