小编Kri*_*rge的帖子

当Angular2中的属性更改时,数据绑定不会更新

我无法弄清楚如何将字段绑定到组件,以便在我更改OnDataUpdate()中的属性时更新字段.

字段"OtherValue"具有对输入字段的双向绑定,"Name"字段在显示组件时显示"test".但是当我刷新数据时,没有任何字段被更新以显示更新的数据.

"this.name"的第一个记录值是未定义的(???),第二个是正确的,但绑定到同一属性的字段不会更新.

组件如何为name-field提供初始值,但是当触发数据更新时,name-property突然未定义?

stuff.component.ts

@Component({
    moduleId: __moduleName,
    selector: 'stuff',
    templateUrl: 'stuff.component.html'
})

export class StuffComponent {
    Name: string = "test";
    OtherValue: string;

    constructor(private dataservice: DataSeriesService) {
        dataservice.subscribe(this.OnDataUpdate);
    }

    OnDataUpdate(data: any) {
        console.log(this.Name);
        this.Name = data.name;
        this.OtherValue = data.otherValue;
        console.log(this.Name);
}
Run Code Online (Sandbox Code Playgroud)

stuff.component.html

<table>
    <tr>
        <th>Name</th>
        <td>{{Name}}</td>
    </tr>
    <tr>
        <th>Other</th>
        <td>{{OtherValue}}</td>
    </tr>
</table>
<input [(ngModel)]="OtherValue" />
Run Code Online (Sandbox Code Playgroud)

html typescript angular

14
推荐指数
1
解决办法
1万
查看次数

无法在服务结构中使用DNS与服务进行通信

我正在尝试获取一个无状态服务来将值发送给另一个服务,只是通过使用服务结构中的DNS服务来实现服务之间的通信。我已经用邮递员测试了这两个应用程序,并且它们工作正常。我正在阅读本教程,在这里看来很简单。

DNS服务已启用: DNS服务正在运行

无状态服务具有DNS名称:在此处输入图片说明 DNS名称在ApplicationManifest.xml中配置

<Service Name="SocketService" 
 ServiceDnsName="SocketService.TimeSeriesActorApplication" 
 ServicePackageActivationMode="ExclusiveProcess">
    <StatelessService ServiceTypeName="SocketServiceType" 
     InstanceCount="[SocketService_InstanceCount]">
       <SingletonPartition />
   </StatelessService>
</Service>
Run Code Online (Sandbox Code Playgroud)

然后,就像教程中一样,我尝试将http get发送到该服务。

using (var client = new HttpClient())
{
 client.BaseAddress = new Uri("http://socketservice.timeseriesactorapplication:8712/api/");
 var response = await client.GetAsync("values");
}
Run Code Online (Sandbox Code Playgroud)

但我有一个例外:

WebException:无法解析远程名称:“ socketservice.timeseriesactorapplication”

当我按照本教程的建议使用端口8080时,以及使用在ServiceManifest.xml中指定的端口时,都会发生这种情况。

<Endpoints>
  <Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="8712" />
</Endpoints>
Run Code Online (Sandbox Code Playgroud)

我在这里想念什么?

更新: 使用localhost代替dns-name也可以正常工作。

Github上的问题:无法解析服务DNS名称#332

c# azure-service-fabric asp.net-core

7
推荐指数
1
解决办法
1661
查看次数

选择更改时停止多选滚动到顶部

我有一个多选列表,用于过滤网格。当我选择或取消选择列表中的任何项目时,它会触发一个事件。

问题是当我向下滚动并选择或取消选择列表中较低的值时,它会跳回顶部。我怎样才能阻止这种情况发生?

我做了一个小提琴:https : //jsfiddle.net/Berge90/a2two97o/

编辑:Chrome 中的问题。在 Edge 和 Firefox 中运行良好

HTML

<div class="FilterContainer">
    <select id="SelectTenant" multiple="true">
    </select><br/>
    <button onclick="setAllTenantSelections(true)">Select All</button>
    <button onclick="setAllTenantSelections(false)">Select None</button>
</div>
Run Code Online (Sandbox Code Playgroud)

Javascript

window.onload = setupFilter;
window.onload = populateTenantFilter;
gridHeaders = [{name: "Test"},{name: "Value"},{name: "Another one"},{name: "And another"},{name: "Last one"}];

//Selecting/Deselecting all values
function setAllTenantSelections(selected) {
    var select = document.getElementById("SelectTenant");
    for (element in select.children) {
        select[element].selected = selected;
        showCol(select[element].text, selected);
    }
}

//Adding all values from array to list
function populateTenantFilter() {
    var select = document.getElementById("SelectTenant"); …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

6
推荐指数
1
解决办法
1493
查看次数

在Azure防火墙中允许ipv6地址

我需要访问在Azure中运行的SQL数据库,但我已经分配了一个ipv6-address.Azure防火墙设置似乎不支持此功能.有没有办法获得访问权限而无需获得新的IP?ip-field中不接受星号.

在此输入图像描述

firewall ipv6 azure azure-sql-database

4
推荐指数
1
解决办法
3354
查看次数

在Azure中托管具有路由的Angular2应用程序

我正在使用角度cli在Angular 2中开发一个应用程序.该应用程序工作正常,并在我在Azure中部署它时运行正常,但路由不起作用.我可以通过"myapp.azurewebsites.net"访问我的应用程序,但如果我尝试"myapp.azurewebsites.net/settings",我会收到404错误.我找到了许多指南,有很多不同的方法可以让不同的服务器将所有内容路由到一个索引文件,但根本没有.就像提供web.config文件,配置节点快速服务器,以及两者同时一样.

所以,我的问题包括两部分.
1. Azure中哪种Web应用程序模板最适合托管Angular2应用程序?
它只是用Angular2编写的单页面应用程序.不是ASP.NET MVC应用程序中包含的那种.

2.如何配置该Web应用程序以使用我在Angular中配置的路由

azure azure-web-sites angular2-routing angular

4
推荐指数
1
解决办法
4139
查看次数

在动画之前获取 Xamarin.Forms ContentView 的高度

我正在尝试创建一个从 Xamarin.Forms 页面顶部发出动画的通知。我非常接近,但在页面上设置 ContentView 的动画之前我无法获取 ContentView 的高度。我制作了一个 xamarin工作簿来演示我的问题,可以在 android 模拟器上运行。(猜测它也可以在 ios/wpf 上工作,并进行一些修改)

该工作簿可在此处获取

问题在于ToastNotificationView.AnimateIn()我首先将整个内容视图的可见性设置为可见(红色背景)。尽管在动画化之前多次尝试将其位置设置在屏幕外,但绿色通知会立即呈现在其最终位置。这种情况仅在通知第一次在页面上动画化时发生,因为它的高度在动画化后可用离开屏幕并再次隐藏。

我可以通过将高度偏移硬编码为 50 来解决这个问题,但要实现可变高度的一致动画,这并不能解决问题。我还可以创建一个方法来计算行数,然后根据该方法动态设置高度,但我希望有一种方法可以实际渲染它,并以某种方式获取组件的实际高度,而不使其对用户可见直到我从我想要的地方开始动画。

public class ToastNotificationView: ContentView {
    // The notification item to be animated in/out
    private StackLayout MainStackLayout;
    public ToastNotificationView() {
        InitializeComponent(); // Let's pretend workbooks supports xaml

        //Subscribing to notification events
        NotificationService.NotificationAppearing += AnimateIn;
        // TODO: Find out how to unsubscribe in contentview without access to life cycle hooks
    }
    private async void OnDismissClicked(object sender, EventArgs e) {
        await AnimateOut(); …
Run Code Online (Sandbox Code Playgroud)

xamarin xamarin.forms

3
推荐指数
1
解决办法
1700
查看次数

Parallel.ForEach比正常foreach慢

我在C#控制台应用程序中使用Parallel.ForEach,但似乎无法正确使用它.我正在创建一个包含随机数的数组,我有一个连续的foreach和一个找到数组中最大值的Parallel.ForEach.使用c ++中大致相同的代码,我开始看到在数组中使用3M值的多个线程的权衡.但即使在100M值下,Parallel.ForEach也是两倍慢.我究竟做错了什么?

class Program
{
    static void Main(string[] args)
    {
        dostuff();

    }

    static void dostuff() {
        Console.WriteLine("How large do you want the array to be?");
        int size = int.Parse(Console.ReadLine());

        int[] arr = new int[size];
        Random rand = new Random();
        for (int i = 0; i < size; i++)
        {
            arr[i] = rand.Next(0, int.MaxValue);
        }

        var watchSeq = System.Diagnostics.Stopwatch.StartNew();
        var largestSeq = FindLargestSequentially(arr);
        watchSeq.Stop();
        var elapsedSeq = watchSeq.ElapsedMilliseconds;
        Console.WriteLine("Finished sequential in: " + elapsedSeq + "ms. Largest = " + largestSeq); …
Run Code Online (Sandbox Code Playgroud)

.net c# parallel-processing parallel.foreach

2
推荐指数
1
解决办法
2986
查看次数

UWP中的多重绑定

我想显示一个具有纬度和经度的文本块。在我的模型中,lat和lng是两个变量,因此我需要将它们组合在一起,最好是与stringformat结合使用,如答案所示。不幸的是,UWP应用程序似乎不支持多重绑定。

这给我留下了两个选择。

  1. 创建绑定到每个变量的两个文本块,并将它们彼此对齐。我不确定是否需要两个额外的文本块才能在值前面显示“ lat”和“ lng”。然后,第三个标签再次在其前面显示“位置”。此答案指出,绑定没有stringformat属性。我认为总共五个文本块太多了。
    <RelativePanel>
        <TextBlock x:Name="EquipmentLatTextBox" 
                   Text="{Binding Equipment.lat}"/>
        <TextBlock x:Name="EquipmentLngTextBox"
                   Text="{Binding Equipment.lng}" 
                   RelativePanel.RightOf="EquipmentLatTextBox"/>
    </RelativePanel>
Run Code Online (Sandbox Code Playgroud)
  1. 创建一个值转换器。这似乎也非常不必要。我明白了使用转换器在数据类型之间进行转换的观点,但是为了隐含字符串,应该在属性中添加buildt。

  2. 在视图模型创建一个属性,该属性返回应显示的值的字符串。这似乎是最好的选择,因为该方法不在模型中,但我仍然认为我应该能够在xaml标记中执行此操作。

有一个更好的方法吗?

xaml uwp uwp-xaml

1
推荐指数
1
解决办法
2579
查看次数