我被这个问题折磨着:我应该在角度项目中的哪里找到我的计算属性?
例如:我有模型、获取模型的服务和显示模型的组件。
人.模型.ts:
export class Person {
firstName: string;
lastName: string;
}
Run Code Online (Sandbox Code Playgroud)
person.service.ts:
export class PersonService {
// inject http: HttpClient
get(id) {
return this.http.get<Person>(`api-endpoint/person/${id}`);
}
}
Run Code Online (Sandbox Code Playgroud)
person.component.ts
@Component({
selector: 'app',
template: `
<div>
<input [value]='person.firstName'>
<input [value]='person.lastName'>
</div>
`,
providers: [ PersonService ]
})
export class AppComponent {
person: Person;
// inject personService: PersonService
ngOnInit() {
personService.get(1).subscribe(p => this.person = p);
}
}
Run Code Online (Sandbox Code Playgroud)
现在我需要fullName将其显示到输入字段下的模板中。
选项 1。如果您搜索“角度计算属性”,您很可能会在组件本身中找到具有计算属性的示例。
@Component({
selector: 'app',
template: `
<div>
<input [value]='person.firstName'>
<input [value]='person.lastName'> …Run Code Online (Sandbox Code Playgroud) binding calculated-field computed-field computed-properties angular
绑定CTRL+的方法S是
new KeyBinding( SaveCommand, Key.S, ModifierKeys.Control )
for CTRL+ Shift+ S是
new KeyBinding( SaveCommand, Key.S, ModifierKeys.Control | ModifierKeys.Shift)
但是,怎么样CTRL+ H+ S?? 有什么建议?
System.Diagnostics.Process.Start("www.google.com");
Run Code Online (Sandbox Code Playgroud)
它工作得很完美,但只是'google.com'怎么样?
我试着这样做
System.Diagnostics.Process.Start("google.com");
Run Code Online (Sandbox Code Playgroud)
但它不适用于相同的链接并引发异常.有什么建议?
我有上下文菜单的datagrid.它以编程方式初始化:
contextMenu = new ContextMenu();
foreach (var col in this.Columns)
{
var checkBox = new MenuItem()
{
Header = col.Header
};
Binding myBinding = new Binding("Visibility");
myBinding.Mode = BindingMode.TwoWay;
myBinding.Converter = new IsCheckedToVisibilityConverter();
checkBox.DataContext = col;
checkBox.SetBinding(MenuItem.IsCheckedProperty, myBinding);
checkBox.Click += checkBox_Click;
checkBox.Checked += checkBox_Checked;
checkBox.Unchecked += checkBox_Unchecked;
contextMenu.Items.Add(checkBox);
}
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但我想在检查\取消选中菜单项后保持打开上下文菜单.有任何想法吗 ?