小编San*_*nde的帖子

Treeview虚拟化和不稳定的滚动

我有一个WPF树视图,其中包含大量嵌套数据,我已启用虚拟化,这对于正在加载的数据而言是有效的.但滚动已变得不稳定,直到整个视图滚动一次然后它解决了一些(仍然不是很好).我已经覆盖了ScrollViewer,我可以看到VirtualizingStackPanel中的范围高度在滚动时发生了不正常的变化.

有谁知道解决这个问题的方法?

任何帮助都是相关的.

下面的TreeView Xaml的相关部分:

        <TreeView  ItemsSource="{Binding Folders.ObservableTree}" Name="FoldersTreeView"
                AutomationProperties.AutomationId="foldersview_treeview_folders" TabIndex="0" PreviewMouseRightButtonDown="OnPreviewMouseRightButtonDown"
                VirtualizingStackPanel.CleanUpVirtualizedItem="VirtualizingStackPanel_OnCleanUpVirtualizedItem" 
                ScrollViewer.VerticalScrollBarVisibility="Auto"
                ScrollViewer.IsDeferredScrollingEnabled ="True"
                VirtualizingStackPanel.IsVirtualizing="True"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                VirtualizingStackPanel.ScrollUnit="Pixel"
                VirtualizingStackPanel.VirtualizationMode="Standard"
                VirtualizingPanel.IsVirtualizingWhenGrouping="True" 
                VirtualizingStackPanel.CacheLengthUnit="Item">

        <TreeView.ItemsPanel>
                <ItemsPanelTemplate>
                <VirtualizingStackPanel IsItemsHost="True" CanVerticallyScroll="True"/>
            </ItemsPanelTemplate>
            </TreeView.ItemsPanel>
        <TreeView.Template>
            <ControlTemplate>
                <view:ScrollViewer2 Padding="{TemplateBinding Control.Padding}" Focusable="False" Name="TreeViewScrollViewer"  
                              CanContentScroll="True">
                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                </view:ScrollViewer2>
            </ControlTemplate>
        </TreeView.Template>
Run Code Online (Sandbox Code Playgroud)

wpf treeview scrollbar

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

RxJS 6 switchMap使用不推荐使用的符号

我已更新Angular 5Angular 6.现在我正在尝试更新我的代码以使其兼容RxJS 6.

.pipe(
  map(job => job[0]),
  switchMap((job) => {
    return job ? this.bookingService.findByID(job.property.id) : Observable.empty();
  }, (job: Job, bookings: Booking[]) => {
    this.mark_jobs_unavailable(job, bookings);
    return job;
  })
)
Run Code Online (Sandbox Code Playgroud)

我正在收到有关使用switchMap的警告Deprecated Symbol is used.

这些是我的进口: import {map, switchMap} from 'rxjs/operators';

在v6中有没有其他方法可以使用switchMap?此外,如果我不更改我的代码rxjs-compat应该使我现有的代码工作(我已经安装)但我得到以下错误相同的代码,但在RxJS 5样式:

.map(job => job[0])
.switchMap((job) => {
    return job ? this.bookingService.findByID(job.property.id) : Observable.empty();
}, (job: Job, bookings: Booking[]) => {
    this.mark_jobs_unavailable(job, bookings);
    return job;
})
Run Code Online (Sandbox Code Playgroud)

Error: Expected 1 argument …

rxjs angularfire2 angular angular5 angular6

7
推荐指数
2
解决办法
5008
查看次数

在app.component.ts中导入HTTP_PROVIDERS

当我尝试从angular/http导入HTTP_PROVIDERS时出现此错误:

Error:(3, 9) TS2305: Module '"projectname/node_modules/@angular/http/index"' has no exported member 'HTTP_PROVIDERS'.
Run Code Online (Sandbox Code Playgroud)

这是我的文件内容:

import { Component } from '@angular/core';
import {GithubService} from './services/github.service';
import {HTTP_PROVIDERS} from  '@angular/http';

@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 2 App</h1><Profile></Profile>',
    providers: [ HTTP_PROVIDERS, GithubService ]
})

export class AppComponent { }
Run Code Online (Sandbox Code Playgroud)

angular

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

角度为2的双向绑定数组

我知道在角度2中有基本的双向绑定,如文档中所示.

我有一个persons 数组,我用它来构建一个HTML列表:

现在,当我点击一个人的行时,我可以使用双向绑定来编辑它:

 <form>
    <label>Name: </label>
    <input [(ngModel)]="selectedPerson.name" name="name"/>

    <label>Description: </label>
    <input [(ngModel)]="selectedPerson.job" name="job"/>
</form>
Run Code Online (Sandbox Code Playgroud)

现在,我想要的是双向绑定列表本身:(列表与行编辑器在不同的视图中)

 <div class='row' *ngFor="let person of model">
    <div class='col'>{{person.name}}</div>
    <div class='col'>{{person.job}}</div>
 </div>
Run Code Online (Sandbox Code Playgroud)

目前,我正在使用*ngFor列出所有人.如果我model是两个人的阵列,我得到两排.有些情况下,model可能会改变为有3或4人.有什么方法可以进行角度检测并相应地添加行?[(ngModel)]这似乎不适用.

基本上,我希望我的列表视图更新,而无需刷新页面.如何model使用于ngFor听取变化?

angular2-directives angular

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

Angular 2,Spring boot,spring security,登录表单

我有一个前端运行应用http:// localhost:4200,与角2(我使用angular-cli用于生成项目).
应用程序运行没有任何问题(我可以使用Angular 2 Http服务从/向数据库获取和发布信息:

getList () {
    return this._http.get("http:// localhost:8080/").map(res => res.json());
}
Run Code Online (Sandbox Code Playgroud)

在另一方面,我有一个后端与正在运行的应用弹簧的引导http:// localhost:8080/(注意端口),这对我提供了一个REST API 角2应用程序.

从发送请求http://localhost:4200/http://localhost:8080/按预期工作.

在我使用spring framework和angularJS 1编写应用程序之前,spring security在同一个应用程序(maven项目)中负责登录和安全性.

现在我有两个独立的应用程序正在通过http(RESTful Api与弹簧启动,前端Api与角度2)

如何设置我的登录表单以及放置它的位置,以及如何使用angular 2应用程序配置弹簧安全性?

spring spring-security spring-boot angular

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

拦截 Apollo/graphql 请求

我们在应用程序中使用 Apollo/Graphql,但遇到了一个问题。

该应用程序是在 Angular 5 中开发的,NodeJS 作为后端,graphql 服务器将响应前端。为了以 Angular 拦截 Http 请求,我们实现了“HttpInterceptor”,以便我们可以以自定义的方式处理错误。但是,Apollo 请求不会通过这个拦截器。

为了正确处理错误,我们使用了“apollo-link-error”。

但是我们想知道是否有可能以类似于 HttpInterceptor 的方式拦截 apollo 请求。

error-handling apollo apollo-client angular express-graphql

6
推荐指数
2
解决办法
8453
查看次数

Dart Cordova+聚合物+Angular2+FastClick

将 Dart Polymer 的纸元素与 Angular 2 一起使用时,如何消除 iOS 设备上约 300 毫秒的点击延迟?

例如,在一个 Angular 2 组件中,如果我有一个包含paper-buttonwith的 HTML 模板(click)="myFunc()",在 iOS 设备中,myFunc 在这个可怕的臭名昭著的延迟之后被调用。

我试过使用 FastClick.js,但是在我将它附加(到身体,或特定的纸按钮)之后,该元素不再可点击,当我点击它时我仍然可以看到涟漪效果,但方法是没有被调用(在移动设备上,但在桌面浏览器中它照常工作),它对paper-input(s)也有相同的影响,它没有得到关注。

可以做些什么吗?也许可以制作一个相当于 FastClick.js 的 Dart/Angular2?

更新 1

值得一提的是,在一个UIWebView(cordova)下,我无法让Angular2.dart和Polymer.dart同时工作,看起来它们不能很好地协同工作,这也是一个障碍,可以使用一些帮助也是如此。

更新 2

来源:https : //github.com/aabluedragon/dart_issue_polymer_angular2_cordova

更新 3

  • 白屏问题:在Cordova下首次运行出现白屏问题,看来与Polymer有关;它与 Angular2 无关。
  • 点击延迟:使用 Polymer 的on-tap事件可以防止点击延迟,但是,这意味着您不能使用 Angular2 的(点击)事件,它不能像 Polymer 那样很好地处理点击。

dart cordova dart-polymer fastclick.js angular

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

Angular 2 Http请求不发送凭据

我正在使用Angular 2,我正在尝试使用凭据发送HTTP请求:

这个Angular 1代码运行良好,它包含凭据:

$http.get("http://some.com/user",{ withCredentials: true})
Run Code Online (Sandbox Code Playgroud)

根据API预览,我已经实现了这个Angular 2代码,但它不包含凭据:

    http.get("http://some.com/user", {
        headers: myHeaders,
        credentials: RequestCredentialsOpts.Include
    }).toRx()
        .map(res => res.json())
        .subscribe(
        // onNext callback
            data => this.successHandler(data),
        // onError callback
            err  => this.failure(err)
    );
Run Code Online (Sandbox Code Playgroud)

我正在使用Angular 2.0.0-alpha.37.

http credentials typescript angular

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

如何使用Angular 2.0的铁列表

我正试图在Angular 2.0中使用铁列表.我已经在使用其他Polymer 1.0组件了,但是铁列表在很大程度上依赖于Light DOM.我知道我可以删除并且只是*ng-列表中的内容,但我认为这不会很好.有人有主意吗.

polymer angular

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

在另一个服务角2中注入服务

我尝试使用角度为2的DI在另一个服务中注入一个服务

import {HttpService} from 'scripts/httpService';
export class CurrentBlog{
    constructor(public httpService:HttpService){}
}
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我收到此错误:

无法解析CurrentBlog(?)的所有参数.确保它们都具有有效的类型或注释.

我用正常组件测试了DI,它工作正常.但是当我注入服务时.它根本不起作用.

typescript angular

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