我有新的翻译问题ng-content.
假设我有一个组件my-component,在其ngOnInit()函数中对加载执行一些繁重的操作(现在,只是一个console.log()).
我有一个包装器,它通过transclusion(my-wrapper.component.html)显示内容.
<ng-content></ng-content>
Run Code Online (Sandbox Code Playgroud)
如果我像这样设置周围环境,则日志语句不会显示:
<my-wrapper *ngIf="false">
<my-component></my-component>
</my-wrapper>
Run Code Online (Sandbox Code Playgroud)
我假设,my-wrapper组件没有构建,因此内容被忽略.
但是,如果我尝试将逻辑移动到my-wrapper像这样的组件(my-wrapper.component.html):
<ng-container *ngIf="false">
<ng-content></ng-content>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
我总是看到console.log()输出.我猜,它my-component会被构建然后存储起来直到*ngIf变成true里面my-wrapper.
目的是建立一个通用的"列表项+细节"组件.假设我有一个N overview-elements(my-wrapper)列表,它们在*ngFor循环中呈现.my-component一旦我决定向特定项目显示更多信息,那么每个元素都有自己的详细信息组件(),它应该加载自己的数据.
overview.html:
<ng-container *ngFor="let item of items">
<my-wrapper>
<my-component id="item.id"></my-component>
</my-wrapper>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
我-wrapper.component.html:
<div (click)="toggleDetail()">Click for more</div>
<div *ngIf="showDetail">
<ng-content></ng-content>
</div>
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉Angular,在有必要将其添加到页面之前忽略已转换的内容?类似于它在AngularJS中的表现.
我在 Tomcat 8 上无法通过 TLS 获得 WebSocket 连接。
我已经设置了以下连接器:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
/>
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystorefile="${user.home}/.keystore" keystorePass="password"
/>
Run Code Online (Sandbox Code Playgroud)
在名为“socket”的标准 Tomcat servlet 中,我在类上使用了 @ServerEndpoint 注释来创建 WebSocket 端点。因此,精简版本如下所示:
@ServerEndpoint(value = "/echo")
public class EchoServer {
@OnOpen
public void onOpen(Session session) {
//
}
@OnMessage
public void onMessage(String message, Session session) {
//
}
@OnClose
public void onClose(Session session) {
//
}
}
Run Code Online (Sandbox Code Playgroud)
在我的客户端,我有一个连接 WebSocket 的 html 脚本:
var webSocket = new WebSocket("ws://localhost:8080/socket/echo");
Run Code Online (Sandbox Code Playgroud)
当我连接到 …
我一直在尝试在ASP.NET MVC项目中使用预先存在的数据库.我创建了一个"数据连接"到我的(Microsoft SQL)数据库(".\ SQLEXPRESS.Databases"),其中包含表"Test".该表有两列,"ID(int)"和"name(nvarchar(MAX))".
在"Models"文件夹中,我放了这个新类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
namespace MvcMovie.Models
{
public class Test
{
public int ID { get; set; }
public string name { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
然后(在"控制器"中)我有一个新的Controller,"HelloWorldController".在这我有这个功能:
public ActionResult Index()
{
DataSet data;
DataTable table;
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
SqlCommand select = new SqlCommand("SELECT * FROM Test", connection);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = select;
data = new DataSet();
adapter.Fill(data, "Test");
table = …Run Code Online (Sandbox Code Playgroud) 我正在使用 C#(ASP.Net、MVC)和 Newtonsoft 进行 JSON 序列化。我得到了一个 XDocument,就像下面我想要的 JSON 格式一样,用于视图。
<group>
<name>Group 1</name>
<description><p>Description</p></description>
<section>
..
</section>
<section>
..
</section>
</group>
Run Code Online (Sandbox Code Playgroud)
我有一个这样的扩展
private static readonly JsonSerializer jSerializer = JsonSerializer.Create(new JsonSerializerSettings {});
public static string ToJson(this object obj) {
using (StringWriter writer = new StringWriter()) {
jSerializer.Serialize(writer, obj);
return writer.ToString();
}
}
Run Code Online (Sandbox Code Playgroud)
现在的问题是,描述被反序列化了,所以我有类似的东西
... "description": { "p": "Description Text" }
Run Code Online (Sandbox Code Playgroud)
当按原样发布时,它将显示为“[Object object]”。
帮助将不胜感激,最好的问候。
我有一个关于 Fortran-OpenMP 和可分配数组的问题。很简单:空间将分配到哪里?如果我有类似的东西
!$omp parallel default(shared) private(arr)
!$omp critical
allocate( arr(BIGNUMBER) )
!$omp end critical
!do calculations with many arr accesses
!$omp critical
deallocate( arr )
!$omp end critical
!$omp end parallel
Run Code Online (Sandbox Code Playgroud)
空间是分配在栈上还是堆上?如果它在堆上,上面的代码和类似的代码之间有区别吗
allocate( arr(BIGNUMBER, nThread) )
!$omp parallel default(shared) private(localArr)
iThread = omp_get_thread_num()
localArr => arr(:, iThread)
!do calculations with many localArr accesses
!$omp end parallel
deallocate( arr )
Run Code Online (Sandbox Code Playgroud)
简短的问题基本上是:哪一个似乎是问题的最佳解决方案?
我有一个简单的 proto 文件,用于创建我的 java 类
syntax = "proto3";
option java_package = "some.project.grpc";
option java_multiple_files = true;
message PingRequest { }
message PingResponse { }
service MyServer {
rpc Ping(PingRequest) returns (PingResponse);
}
Run Code Online (Sandbox Code Playgroud)
使用 gradle 和 google protobuf 插件(https://github.com/google/protobuf-gradle-plugin)我创建了我的类
gradle generateProto
Run Code Online (Sandbox Code Playgroud)
生成的MyServerGrpc有一个内部类MyServerBlockingStub,它有两个构造函数:
private MyServerBlockingStub(io.grpc.Channel channel) { ... }
private MyServerBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { ... }
Run Code Online (Sandbox Code Playgroud)
该MyServerGrpc课程确实将第一个公开为newBlockingStub(io.grpc.Channel channel)但不是第二个 - 我需要。
像这样,我无法设置任何呼叫选项,例如超时。我可以轻松地操作生成的文件以允许我访问我需要的构造函数,但是这些更改将在下一代中丢失 - 所以这不是一个真正的选择。
由于这看起来很容易解决,我在想:
CallOptions对象设置在我还没有找到的其他地方?c# ×2
angular ×1
arrays ×1
asp.net-mvc ×1
database ×1
fortran ×1
gradle ×1
grpc ×1
heap-memory ×1
html ×1
https ×1
java ×1
json ×1
json.net ×1
linq-to-xml ×1
openmp ×1
properties ×1
sockets ×1
ssl ×1
stack-memory ×1
tomcat ×1
typescript ×1
view ×1
websocket ×1