小编Dan*_*Dan的帖子

如何使用 ng2-file-upload 选择图像后立即显示图像?

我正在使用 angular2 构建一个网站,并使用 ng2-file-upload 库ng2-file-upload 我想在选择图像后立即在我的网站上显示图像。这个库怎么可能做到这一点?

angular

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

如何在angular4单元测试中忽略第三方组件的html标签?

我查看了文档,检查了SO,并尝试了不同的解决方案/解决方案,我似乎无法让它工作.我正在为带有karma/jasmine的angular4应用程序编写单元测试.它测试使用第三方组件ckeditor的组件(https://www.npmjs.com/package/ng2-ckeditor).虽然当我运行测试时我得到了这个错误......

失败:未捕获(在承诺中):错误:模板解析错误:'ckeditor'不是已知元素:1.如果'ckeditor'是Angular组件,则验证它是否是此模块的一部分.2.要允许任何元素将'NO_ERRORS_SCHEMA'添加到此组件的'@NgModule.schemas'.("[错误 - >]

"):ng:///DynamicTestModule/CkEditorComponent.html@0:0错误:模板解析错误:'ckeditor'不是已知元素:1.如果'ckeditor'是Angular组件,则验证它是否属于2.允许任何元素将'NO_ERRORS_SCHEMA'添加到此组件的'@ NgModule.schemas'.("[ERROR - >]"):ng:///DynamicTestModule/CkEditorComponent.html@0:0. ..

我的单元测试文件看起来像这样

import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ManageInvanareLoginComponent } from './manage-invanare-login.component';
import {CreateDriftInfoComponent} from "../create-drift-info/create-drift-info.component";
import {CreateLoginTextComponent} from "../create-login-text/create-login-text.component";
import {MdInputContainer, MdInputModule} from "@angular/material";
import {CKEditorModule} from "ng2-ckeditor";
import {CkEditorComponent} from "../ck-editor/ck-editor.component";

describe('ManageInvanareLoginComponent', () => {
  let component: ManageInvanareLoginComponent;
  let fixture: ComponentFixture<ManageInvanareLoginComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        CkEditorComponent,
        CreateDriftInfoComponent,
        CreateLoginTextComponent,
        ManageInvanareLoginComponent,
        MdInputContainer
      ],
      providers:[
        CKEditorModule,
        MdInputModule
      ]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture …
Run Code Online (Sandbox Code Playgroud)

unit-testing karma-jasmine angular

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

如何使用 terraform 在 for 循环中创建多个资源?

我查看了一些文档以及有关 terraform 的 udemy 课程,但我不明白如何做我想做的事情。我想创建一个 for 循环,并在其中创建一个 S3 事件通知,创建一个侦听该通知的 Sns 主题,创建一个 Sqs 队列,然后将该队列订阅到该 sns 主题。似乎 terraform 中的 for 循环不够先进,无法做到这一点。我错了,是否有任何文档或示例可以解释如何在此用例中使用 for 循环?

提前致谢。

terraform

4
推荐指数
2
解决办法
5785
查看次数

如何更改React Native Drawer.Navigator的菜单图标颜色?

我正在构建一个反应本机应用程序。我正在使用这个抽屉导航器(https://reactnavigation.org/docs/drawer-navigator/)组件。很清楚如何更改标题部分的文本,但不清楚如何更改标题图标的颜色。目前我的代码如下所示。

  <Drawer.Navigator
    initialRouteName="Calendar"
    screenOptions={{
      drawerStyle: {
        width: 240
      },
      headerTintColor: {color: KbStyles.white},
      headerStyle: {
        height: 80,
        backgroundColor: KbStyles.green
      },

      headerTitleStyle: {
        color: KbStyles.white
      },
      drawerActiveBackgroundColor : KbStyles.lightRed,
      drawerActiveTintColor: "white"
    }}
Run Code Online (Sandbox Code Playgroud)

此代码成功更改了文本的颜色,但没有更改标题图标。它看起来像这样:

它看起来像这样:

如何将该菜单图标的颜色更改为白色?

react-native

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

如何在本地tomcat服务器上部署angular2应用程序?

我一直在用lite服务器开发一个angular2应用程序.现在我想在tomcat服务器上部署这个应用程序以连接java后端.我一直在使用角度cli.我使用命令'ng build -prod'来生成dist文件夹.根据angular2的udemy教程,该文件夹的内容是部署angular2项目所需的全部内容.我将此文件夹的内容放在java项目的WebContent文件夹中,然后单击eclipse IDE中的绿色按钮开始提供文件.在其他项目中,我可以用这种方式成功部署html和javscript文件.但是对于这个angular2项目,"正在加载..."出现,应用程序永远不会启动.控制台显示这些错误.

GET http:// localhost:8080/vendor/es6-shim/es6-shim.js [HTTP/1.1 404 Not Found 3ms] GET http:// localhost:8080/vendor/reflect-metadata/Reflect.js [HTTP/1.1 404未找到4ms] GET http:// localhost:8080/vendor/systemjs/dist/system.src.js [HTTP/1.1 404 Not Found 4ms] GET http:// localhost:8080/vendor/zone.js/dist/zone.js [HTTP/1.1 404 Not Found 4ms] GET http:// localhost:8080/vendor/reflect-metadata/Reflect.js [HTTP/1.1 404 Not Found 1ms] GET http:// localhost:8080/vendor/systemjs/dist/system.src.js [HTTP/1.1 404 Not Found 2ms] GET http:// localhost:8080/vendor/zone.js/dist/zone.js [HTTP/1.1 404 Not Found 2ms] ReferenceError :系统未定义

这些错误对我来说似乎很奇怪,因为我在这些位置看到了文件.

当我在angular2 cli项目文件夹中运行服务时,该应用程序运行正常.

如何在不运行light服务器的情况下在tomcat服务器中部署dist文件夹,或者轻型服务器可能需要同时运行?做这个的最好方式是什么?

tomcat angular

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

如何正确改变带有角度的垫子图标的颜色?

我看了看文档,并尝试像下面这样更改mat-icon的颜色:

<mat-icon class="white" color="primary" svgIcon="back"></mat-icon><span class="backText">back</span>
Run Code Online (Sandbox Code Playgroud)

以上是元素在html中的外观。我试图通过添加带有白色的类来更改图标的颜色。哪个不起作用。我尝试添加指令color =“ primary”,当我的所有按钮看起来像这样时,该指令也不起作用

 <button mat-button color='primary'>example button</button>
Run Code Online (Sandbox Code Playgroud)

会收到颜色。我想让我的Mat-icon用调色板更改颜色,因为这应该根据文档工作。但最终,我还希望能够将图标的颜色更改为白色,这是我的调色板上没有的颜色。

如何<mat-icon>从可用的调色板以及不在调色板上的颜色更改其颜色?

谢谢!

angular-material angular

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

如何解决java.net.BindException:地址已在使用中

我试图通过数学海洋在ubuntu 14上设置一个tomcat 8服务器,使用本教程https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu- 14-04.但是我无法访问tomcat的启动页面.

一切顺利,直到我到达启动tomcat的步骤

sudo initctl启动tomcat

这会返回一条消息

tomcat启动/运行,进程9180

但是当我输入网址时

我滴-IP地址:8080

启动页面永远不会加载.

我已经读过你可以用tomcat启动它了

sh startup.sh

虽然我这样做catalina.out给了我错误信息

31-Jul-2016 05:37:41.018 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
31-Jul-2016 05:37:41.086 SEVERE [main] org.apache.coyote.AbstractProtocol.init Failed to initialize end point associated with ProtocolHandler ["http-nio-8080"]
 java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:433)
    at sun.nio.ch.Net.bind(Net.java:425)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:229)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:866)
    at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:213)
    at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:558)
    at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:65)
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:1010)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    at org.apache.catalina.core.StandardService.initInternal(StandardService.java:549)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:873)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:606) …
Run Code Online (Sandbox Code Playgroud)

java linux tomcat8 digital-ocean ubuntu-14.04

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

如何在angular4中更改md-input-container的下划线颜色?

我一直在阅读这方面的文档(https://material.angular.io/components/input/overview)有一节说明如何更改md-input-container底部的行颜色.但我不清楚属性是什么,也没有代码示例可供参考.它表示可以使用md-input-container的color属性更改下划线颜色.另外我的下划线是动画下划线,在提供的链接中可见.有人可以更清楚地解释md-input-container的属性是什么,或提供一些代码.我已经尝试添加一个名为color的指令,在css中更改md-input-container的颜色等等,我没有成功.如果有人可以解释/显示一些证明这一点的代码,那将非常有帮助.谢谢!

这是一些代码,我觉得应该根据该文本的措辞.但事实并非如此.

  <md-input-container
    color="yellow"
    class="input-half-width">
    <input
      [(ngModel)]="driftInfo.title"
      name="title"
      mdInput
      placeholder="Ange rubrik"
    >
  </md-input-container>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

material-design angular-material2 angular

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

如何对2个表进行连接,但只返回一张表的数据?

我不确定这是否可能。但是是否可以对 2 个表进行联接,但仅返回其中一个表的数据。我想根据条件连接两个表,但我只想要其中一个表的数据。这可以用 SQL 实现吗?如果可以的话怎么实现?阅读文档后,似乎当您进行联接时,您会获得两个表的数据。谢谢你的帮助!

mysql sql

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

如何让本地 dynamodb 运行以便我的 java 应用程序可以连接它?

我查看了几个 stackoverflow 帖子以及 dynamodb 的 AWS 文档来回答这个问题。我希望能够在 docker 中运行本地 dynamodb,然后从我本地运行的 java 应用程序连接到它。我已经安装了 amazon/dynamodb-local 映像并使其正常工作。我什至使用 aws cli 在这个本地运行的 dynamodb 上创建表、列出表、删除表等。我在 java 项目中安装了 dynamodb sdk 依赖项,我觉得我已经把所有东西都连接起来了,运行了一个集成测试,然后我收到了这个错误消息

com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException:无法对不存在的表进行操作(服务:AmazonDynamoDBv2;状态代码:400;错误代码:ResourceNotFoundException;请求 ID:c915ea26-008e-4a9f-8b99-6df5d6aa7c)

当使用 aws cli 运行 list-tables 函数时,该表确实存在,所以我用谷歌搜索,然后检查了文档dynamodb 文档,似乎您必须使用标志启动本地 dynamodb

-sharedDb

我通过尝试使用此命令启动本地运行的 dynamodb 来尝试此操作

docker run -p 8000:8000 amazon/dynamodb-local -sharedDb
Run Code Online (Sandbox Code Playgroud)

虽然我得到了错误

无法识别的选项:-sharedDb 错误:无法创建 Java 虚拟机。错误:发生了致命异常。程序将会退出。

在此之后我尝试使用谷歌搜索或寻找有类似问题的人。但我什么也没找到。如何启动本地运行的 dynamodb 并从本地运行的 Java 应用程序连接到它?

java amazon-dynamodb docker

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

为什么angular2找不到index.html中导入的样式表?

我有一个带有 index.html 文件的 angular2 应用程序。我在index.html中有这一行

链接 rel="stylesheet" type="text/css" href="styles.css"

样式表就在那里,并且实际上已加载,因为它通过应用 styles.css 中定义的样式来影响页面。

但这个错误是在控制台中抛出的。

无法加载资源:服务器响应状态为 404(未找到)

我已经有一段时间遇到这个错误了,一直以为我会稍后处理它,并认为它与旧版本的 Angular 2 有关。但现在我在 2.3.1 上,错误仍然抛出在控制台中。我该如何解决这个问题?

索引.html

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>MemberAdmin</title>
  <base href="/">

  <link rel="stylesheet" type="text/css" href="styles.css">

  <script type="text/javascript" src="assets/IndexResources/jquery.js"></script>

  <!--<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" media="all">-->

  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">


  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>


  <!--<link rel="stylesheet" type="text/css" href="assets/IndexResources/angular-calendar.css">-->

  <link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">


  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="./assets/smalllogo.png">
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

文件夹结构:

在此输入图像描述

在此输入图像描述

angular

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

在多个环境中使用的angular4应用程序中编码URL的最佳做法是什么?

我有一个角度4应用程序,我试图找到一种最佳实践方法来创建一个解决方案来创建一个服务或某种解决方案来处理许多网址,以便在开发和生产环境中发出http请求.

此时我的解决方案看起来像这样.

import { Injectable } from '@angular/core';
/**
 * PathsService is like a properties file for all of the URL paths used in the application.
 */
@Injectable()
export class PathsService {

  constructor() {}

  productionEnvironment:string = "https://myproductionenvironment.com"
  developmentEnvironment:string = "https://mydevelopmentenvironment.com"

  activeRoot:string = productionEnvironment;


  loginResource = "/loginresources"
  employeeResource = "/employeeresouces"

  public getLoginResources(): string {
    return this.activeRoot+this.loginResource;
  }

  public getEmployeeResource():string {
    return this.activeRoot+this.employeeResource;
  }




}
Run Code Online (Sandbox Code Playgroud)

虽然我相信这样可以正常工作,但是存在一个小问题,因为我必须在从开发环境切换到生产环境时更改activeRoot.我想知道是否有更好的方法来做到这一点,所以我不必手动切换.我可以使用javascript来获取url,解析它,并以这种方式在生产和开发环境之间切换,但似乎应该有更好的角度方式来解决这个问题.关于这个问题的任何意见将不胜感激.谢谢!

angular-http angular

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