小编Dan*_*ray的帖子

错误错误:StaticInjectorError(AppModule)[UserformService - > HttpClient]:

在尝试添加PrimeNG表时,我在这里打破了我的构建:https://github.com/BillyCharter87/Tech-O-Dex-UI/tree/BrokeIt

我记得将我package.json从TypeScript 2.3.4 更新到2.4.0并且由于(我认为)我正在使用HeadersHttp我的POST调用而破坏了它.我尝试将其设置回2.3.4无济于事.我已经修改了我可以添加的内容:

import { HttpClient, HttpHeaders } from "@angular/common/http";
Run Code Online (Sandbox Code Playgroud)

但仍然遇到我现在的错误HttpClient.我尝试HttpClient像这样导入提供程序:providers: [HttpClient]for app.module.ts.

完整错误如下:

AppComponent.html:9 ERROR Error: StaticInjectorError(AppModule)[HttpClient -> HttpHandler]: 
StaticInjectorError(Platform: core)[HttpClient -> HttpHandler]: 
NullInjectorError: No provider for HttpHandler!
Run Code Online (Sandbox Code Playgroud)

angular angular4-httpclient

35
推荐指数
5
解决办法
12万
查看次数

Twitter bootstrap模式无法正常工作

我是Twitter Bootstrap的新手.我正在使用模态面板,但它没有显示.它会淡化屏幕,但模式本身不会出现.我检查了错误控制台,没有错误.

我的代码在<head>标签内; 我包括以下脚本:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo $ruadmin ?>js/bootstrap.js"></script>
<script src="<?php echo $ruadmin ?>js/tablesorter/jquery.tablesorter.js"></script>
<script src="<?php echo $ruadmin ?>js/tablesorter/tables.js"></script>
Run Code Online (Sandbox Code Playgroud)

模态页面:

<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-large">Launch demo modal</a>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Welcome</h3>
  </div>
  <div class="modal-body">
    <p> Hello </p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript jquery modal-dialog twitter-bootstrap

29
推荐指数
3
解决办法
9万
查看次数

如何使用基于另一个列表的lambda从列表中删除元素

我有文件路径列表:.

List<Path> filePaths; //e.g. [src\test\resources\file\15\54\54_exampleFile.pdf]
Run Code Online (Sandbox Code Playgroud)

54 以上是指文件ID

然后,我获得了一个我的应用程序可以处理SetStringID,如下所示:

Set<String> acceptedIds = connection.getAcceptedIDs(); //e.g. elements [64, 101, 33]
Run Code Online (Sandbox Code Playgroud)

如何使用Java 8 lambdas来filter排除filePaths其中不包含acceptedIds集合Set中包含的任何可接受的ID的所有元素.

换句话说,我只想保留filePaths具有acceptedIdsset中的id的路径.例如,54不在上面的列表中,因此被删除.

filePaths.stream().filter(...).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)

java lambda java-8 java-stream

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

如何将 i32 数字的 Vec&lt;&gt; 连接到字符串中?

我想将数字列表连接到字符串中。我有以下代码:

let ids: Vec<i32> = Vec::new();
ids.push(1);
ids.push(2);
ids.push(3);
ids.push(4);
let joined = ids.join(",");
print!("{}", joined);
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下编译错误:

error[E0599]: no method named `join` found for struct `std::vec::Vec<i32>` in the current scope
  --> src\data\words.rs:95:22
   |
95 |     let joined = ids.join(",");
   |                      ^^^^ method not found in `std::vec::Vec<i32>`
   |
   = note: the method `join` exists but the following trait bounds were not satisfied:
           `<[i32] as std::slice::Join<_>>::Output = _`
Run Code Online (Sandbox Code Playgroud)

我有点不清楚该怎么办。我了解特征的实现,但无论它期望什么特征,我都希望能够在本机实现i32. 我希望将整数连接到字符串中比这更简单。我应该把它们全部投给Strings 吗?

编辑:这与链接的问题不同,因为在这里我特别询问数字不是直接的“join能够”,以及该特征不能由数字类型实现的原因。我在这个方向上相当努力地寻找一些东西,但一无所获,这就是我问这个问题的原因。

此外,更有可能有人会专门搜索这样的问题,而不是更一般的“迭代器值的惯用打印”。

rust

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

如何使通用TypeScript接口从另一个通用接口扩展?

我有一个界面,其中包含几个元素:

export interface Item {
  id: string;
  code: string;
  createdAt: string;
  updatedAt: string;
  level: number;
  seq: number;
  hasChildren: boolean;

  parentObject?: Item;
  children?: Item[];
}
Run Code Online (Sandbox Code Playgroud)

我想要类似的东西Partial<T>,我在这里很有帮助在Typescript界面​​中将所有属性设置为可选

但是,我想将其中一项设为必填项。我实现了这一点:

export interface ItemUpdate extends Partial<Item> {
  id: string;
}
Run Code Online (Sandbox Code Playgroud)

而且编译良好。但是,我想避免为每个接口都声明它。为此,我使它更通用:

export interface UpdateOf<T> extends Partial<T> {
  id: string; // the ID is the only mandatory value for an update
}
Run Code Online (Sandbox Code Playgroud)

但是,它不再编译,返回以下错误:

error TS2312: An interface may only extend a class or another interface.
Run Code Online (Sandbox Code Playgroud)

我正在运行Angular 6.1.5,它随Typescript 2.9一起提供(据我所知)。

typescript

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

春季会议和春季安全

我对以下方面有疑问:春季会议和春季安全.

春季会议

我有一个受Spring Security保护的应用程序,通过示例示例中提供的基本内存中身份验证.

我看到spring正在创建会话ID,即使身份验证不成功,这意味着x-auth-token即使我不提供基本身份验证凭据详细信息,我也会在Redis数据库中看到我的响应标头.我们如何避免为身份验证失败创建会话?

春季安全

假设spring会话仅为受保护资源创建会话,则希望使用spring security来保护资源.

假设Signin API(/ signin - HTTP Post)针对第三方REST API验证(用户名和密码)凭据.

外部API验证凭据后,如何在成功验证时更新spring安全上下文?

应提供对x-auth-token需要验证的其他安全资源的访问,并基于对安全资源的信息访问.

在这种情况下我们是否需要Spring Security或者我应该使用基本的过滤器和弹簧会话?推荐什么?

spring-security spring-session

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

使用 Mojo::Log 的正确方法是什么?

我想使用 MojoliciousMojo::Log工具来登录我的 Mojolicious Web 应用程序。但是,我不确定使用它的正确/正确方法。

文档显示它直接从脚本中使用,但没有说明它是否是线程安全的或在控制器之间共享是否安全,或者每个控制器是否应该实例化自己的Mojo::Log对象(在这种情况下,所有控制器都可以安全地使用它吗?指向同一个日志文件?)。

使用此记录器的正确方法是什么?

perl mojolicious

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

JPA @Entity继承

我一直在研究JPA/Hibernate @Entity继承一段时间,似乎无法找到解决我想要实现的问题的任何东西.

基本上我希望能够根据需要定义@Entity所有列和表映射.然后,我希望能够使用@Entity@Transient每个"子实体"的主体中定义的不同方法集来扩展许多不同的位置.这是我想要实现的基本示例,但到目前为止没有成功:

@Entity
@Table(name = "mountain")
public class MountainEntityBase implements Serializable {
    public Integer mountainId = 0;
    public Integer height = 0;

    public List<ExplorerEntityBase> explorers = new ArrayList<ExplorerEntityBase>();

    @Id
    @GeneratedValue
    @Column(name = "mountain_id")
    public Integer getMountainId() { return mountainId; }
    public void setMountainId(Integer mountainId) { this.mountainId = mountainId; }

    @Column(name="height")
    public String getHeight() { return height; }
    public void setHeight(String height) { this.height = height; }

    @OneToMany(mappedBy="mountainId")
    public List<ExplorerEntityBase> getExplorers() { return …
Run Code Online (Sandbox Code Playgroud)

java inheritance persistence hibernate jpa

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

如何样式 createMaterialBottomTabNavigator?

底部标签栏

我正在使用react-navigation-material-bottom-tabs此导航栏。唯一的问题是我无法控制标签的样式或条形高度。除了使用顶部栏并将其定位到底部之外,我还能做什么?

export default HomeScreenTabNavigator = new 
                              createMaterialBottomTabNavigator({
       NewsFeed: { screen: FeedStack},
       Social: { screen: SocialStack},
       Planner: { screen: PlannerStack},
       Boring: { screen: BoringStack},
       Account: { screen: AccountStack},
   },
   {
       navigationOptions: ({ navigation }) => ({
           tabBarIcon: ({ focused, tintColor }) => {
               const { routeName } = navigation.state;
               let iconName;
               if (routeName === 'Boring') {
                   iconName = `ios-add-circle${focused ? '' : '-outline'}`;
               } else if (routeName === 'Social') {
                   iconName = `ios-alarm${focused ? '' : '-outline'}`;
               } …
Run Code Online (Sandbox Code Playgroud)

react-native react-navigation

6
推荐指数
0
解决办法
2382
查看次数

在Angular服务构造函数中调用HTTP端点可以吗?

Angular文档中,有以下关于组件构造函数中代码的提示(我强调的第二段):

叫进去 ngOnInit

虽然可以调用getHeroes()构造函数,但这不是最佳实践。

保留构造函数以进行简单的初始化,例如将构造函数参数连接到属性。构造函数不应该做任何事情。当然,不应像真正的数据服务那样调用向远程服务器发出HTTP请求的函数。

而是getHeroes()ngOnInit生命周期挂钩内调用ngOnInit,并构造HeroesComponent实例的适当时间让Angular调用。

服务方面呢?Observable在构造函数中进行HTTP调用(只是在本地存储异步请求的启动)是否也很糟糕?服务没有ngOnInit()事件,那么服务的最佳实践是什么?

angular

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