你好,我想用这种格式的语言创建路线:
www.domain.com/lang/sometimes
Run Code Online (Sandbox Code Playgroud)
例子:
www.domain.com/en/sometimes
www.domain.com/de/sometimes
Run Code Online (Sandbox Code Playgroud)
是否可以编写路由类似的内容:
RouterModule.forChild({
path: ':lang/sometimes', component: TestComponent
})
Run Code Online (Sandbox Code Playgroud)
是否可以?如何设置为url默认语言?例如在应用程序启动时,动态设置 lang 参数为 url。
谢谢你的建议
我需要提取所有类变量。但是我的代码返回所有变量,包括在方法(本地)中声明的变量。例如:
class MyClass
{
private int x;
private int y;
public void MyMethod()
{
int z = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
我只需要得到xandy但我得到x, y, 和z。到目前为止我的代码:
SyntaxTree tree = CSharpSyntaxTree.ParseText(content);
IEnumerable<SyntaxNode> nodes = ((CompilationUnitSyntax) tree.GetRoot()).DescendantNodes();
List<ClassDeclarationSyntax> classDeclarationList = nodes
.OfType<ClassDeclarationSyntax>().ToList();
classDeclarationList.ForEach(cls =>
{
List<MemberDeclarationSyntax> memberDeclarationSyntax = cls.Members.ToList();
memberDeclarationSyntax.ForEach(x =>
{
//contains all variables
List<VariableDeclarationSyntax> variables = x.DescendantNodes()
.OfType<VariableDeclarationSyntax>().ToList();
});
});
Run Code Online (Sandbox Code Playgroud) 我想在 Angular 中将我的应用程序部署到生产服务器,但我遇到了问题。当我只使用角度路由(更改组件,而不是重定向)时,应用程序可以正常工作,但是当我在浏览器中刷新页面时,我得到一个从 IIS 返回的 404 页面(我使用 IIS 作为 Web 服务器)
这是我的角度路由:
const appRoutes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full', canActivate: [AuthGuard] },
{ path: 'home', component: DashboardComponent, canActivate: [AuthGuard] },
{ path: "profile", component: UserProfileComponent, canActivate: [AuthGuard] },
{ path: '400', component: ErrorComponent },
{ path: '401', component: ErrorComponent },
{ path: '403', component: ErrorComponent },
{ path: '404', component: ErrorComponent },
{ path: '500', component: ErrorComponent },
{ path: '503', component: ErrorComponent },
{ …Run Code Online (Sandbox Code Playgroud) 我想在模式窗口中单击关闭按钮时触发一个事件。按钮有属性data-dismiss="modal",不调用click事件。是否有可能有数据关闭和click事件或只有click事件和关闭类的模式?
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" (click)="close()">×</button>
<h4 class="modal-title">{{modalHeader}}</h4>
</div>
</div>
</div>
close() {
//Can I close modal window manually?
this.onClose.emit();
}
Run Code Online (Sandbox Code Playgroud)
方法close不调用,因为按钮有data-dismiss属性。
谢谢
我有一个简单的问题.如何使用http状态代码从控制器重定向到自定义错误页面?例如:
public ActionResult Index()
{
this.Redirect("Not found", 404); //redirect to my error page with code 404
}
Run Code Online (Sandbox Code Playgroud) 您好,我想创建具有嵌入功能并将数据从子组件传递到父组件的组件。我的想法在这里:
列表组件模板:
<ul>
<li ng-repeat="item in $ctrl.list"><ng-transclude></ng-transclude></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
使用
<list-component>
<strong>{{itemFromComponent.name}}<strong>
//how to get item from list-component to here??
</list-component>
Run Code Online (Sandbox Code Playgroud)
请告诉我如何将当前项目从组件传递到父级以便能够看到它。谢谢
我有个问题。我想在 ASP 控制器中创建这个 json 结构:
{
"title": "T1",
"data": [
{ "value": "v1", "key": "k1" },
{ "value": "v2", "key": "k2" }
]
}
Run Code Online (Sandbox Code Playgroud)
我试过这个:
var data = new
{
title = "T1",
data = new[]
{
new
{
value = "V1",
key= "K1"
},
new
{
value = "V2",
key= "K2"
}
}
};
Run Code Online (Sandbox Code Playgroud)
谢谢你的建议
我有这个数组:
[{a: 1, b: 2}, {a: 2, b: 3}, {a: 3, b: 1},...]
Run Code Online (Sandbox Code Playgroud)
我想转换为这个数组:
[{a:1}, {a:2}, {a: 3}]
Run Code Online (Sandbox Code Playgroud)
我试过这个:
array.map(x => {'a': x.a})
Run Code Online (Sandbox Code Playgroud)
但这是一个错误(给出错误).JavaScript中有没有可以执行此操作的功能?谢谢
我想问问是否可以使用routerLink再次打开当前页面。我有这个菜单:
<ul>
<li><a routerLink="home">Home</a></li>
<li><a routerLink="users">Users</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
当当前URL是www.domain.com/users我想单击菜单中的“用户”并刷新此页面时。有可能的?我知道我用过,location.reload()但它会重定向整页。
我试图ngModel从文本输入绑定,但它不起作用.这是我的代码:
模板:
<form (ngSubmit)="onSubmit()">
<div class="form-group">
<input type="text" class="form-control" [(ngModel)]="message">
</div>
<input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
零件:
export class Component implements OnInit {
message:string
onSubmit() {
console.log(this.message);
}
}
Run Code Online (Sandbox Code Playgroud)
总是得到未定义的价值.如何将文本输入中的值绑定到变量?
你好,我有一个 jquery datetimepicker 的问题。我想在周一(现在是周日)一周的开始时显示日历。我用过firstDay,但没有任何作用。这是我的代码:
jQuery(document).ready(function () {
'use strict';
jQuery.datetimepicker.setLocale('cs');
jQuery('#startDate, #endDate').datetimepicker({
format: 'd.m.Y H:i',
firstDay: 1,
step: 15
});
});
<input class="form-control" id="startDate" datetime-picker />
Run Code Online (Sandbox Code Playgroud)
如何显示以星期一为一周开始的日历?谢谢