小编tak*_*adi的帖子

基于数字使用ngFor多次重复HTML元素

如何使用*ngFor多次重复HTML元素?

例如:如果我将成员变量赋值为20.如何使用*ngFor指令使div重复20次?

angular

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

highlight.js不适用于Angular 2

我正在尝试使用highlight.js为我的应用程序添加语法高亮,但它似乎不适用于Angular 2.

你能不能让我知道我可能做错了什么?

这是Plnkr:https://plnkr.co/edit/G3NFFPGXKyc9mV1a6ufJ p = preview

这是组件

import {Component} from 'angular2/core';

@Component({
    selector: "my-app",
    template: `
      Hello!
      <pre>
        <code class="html">
          &lt;html&gt;
            &lt;body&gt;

            &lt;h1&gt;My First Heading&lt;/h1&gt;
            &lt;p&gt;My first paragraph.&lt;/p&gt;

            &lt;/body&gt;
          &lt;/html&gt;
        </code>
      </pre>
    `
})
export class AppComponent{
}
Run Code Online (Sandbox Code Playgroud)

这是我使用cdn添加highlight.js的地方:

<!DOCTYPE html>
<html>

<head>
  <!-- IE required polyfills, in this exact order -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.25/system-polyfills.js"></script>
  <script src="https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js"></script>

  <!-- Angular polyfill required everywhere -->
  <script src="https://code.angularjs.org/2.0.0-beta.13/angular2-polyfills.js"></script>

  <script src="https://code.angularjs.org/tools/system.js"></script>
  <script src="https://code.angularjs.org/tools/typescript.js"></script>
  <script src="https://code.angularjs.org/2.0.0-beta.13/Rx.js"></script>
  <script src="https://code.angularjs.org/2.0.0-beta.13/angular2.dev.js"></script>
  <link rel="stylesheet" …
Run Code Online (Sandbox Code Playgroud)

syntax-highlighting highlight.js angular

8
推荐指数
2
解决办法
6304
查看次数

使用Clarity设计系统构建Angular 2应用程序

将Clarity Design System从他们的官方教程添加到角度为2 5min的快速入门后,我收到了这个错误.浏览器控制台中的错误没有太大帮助,请问有什么建议吗?

zone.js:1382 GET http://localhost:3000/clarity-angular 404 (Not Found)
Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/clarity-angular(…)
Run Code Online (Sandbox Code Playgroud)

app.module.ts

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ClarityModule} from 'clarity-angular';
import {AppComponent} from './app.component';

@NgModule({
  imports: [BrowserModule,
            ClarityModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {
}
Run Code Online (Sandbox Code Playgroud)

的index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="styles.css">

    <link rel="stylesheet" href="node_modules/clarity-icons/clarity-icons.min.css">
    <script src="node_modules/mutationobserver-shim/dist/mutationobserver.min.js"></script>
    <script src="node_modules/@webcomponents/custom-elements/custom-elements.min.js"></script>
    <script src="node_modules/clarity-icons/clarity-icons.min.js"></script>
    <link rel="stylesheet" …
Run Code Online (Sandbox Code Playgroud)

javascript clarity systemjs angular vmware-clarity

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

java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager

我在 Android 应用程序中使用 Mashape 的 API。Mashape 推荐使用 Unirest 库。我已经包含了 unirest 链接中提到的依赖项:http ://unirest.io/java

我的依赖:

compile fileTree(dir: 'libs', include: ['*.jar'])
compile group:'com.mashape.unirest', name:'unirest-java', version:'1.3.26'
compile group:'org.apache.httpcomponents', name:'httpcore', version:'4.3.3'
compile group:'org.apache.httpcomponents', name:'httpclient', version:'4.3.6'
compile group:'org.apache.httpcomponents', name:'httpasyncclient', version:'4.0.2'
compile group:'org.apache.httpcomponents', name:'httpmime', version:'4.3.5'
compile group:'org.json', name:'json', version:'20141113'
compile 'com.android.support:appcompat-v7:21.0.+'
Run Code Online (Sandbox Code Playgroud)

当我发出 HTTPRequest 时,我仍然收到此错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
    at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:153)
    at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:133)
    at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
Disconnected from the target VM, address: '127.0.0.1:58805', transport: 'socket'

Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.HttpClientConnectionManager
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method) …
Run Code Online (Sandbox Code Playgroud)

java android classpath

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

Javascript HTML 5 Progress Bar无法使用setInterval

  1. 单击按钮时,进度条增加1.但是我没有看到它增加到100.我必须一次又一次地点击按钮来增加值.你能否告诉我,我可能做错了什么?
  2. 另外,如果不使用进度条ID,如何在每个进度条达到100时清除每个进度条的间隔?

window.onload = function() {
  console.log("Hello");
  var button = document.getElementById("animateButton");
  button.onclick = goProgress;
}

function goProgress() {
	console.log("In goProgress()");
  var progressBars = document.getElementsByClassName("progress");
  for(var i=0;i<progressBars.length;i++){
    console.log("Progress Bar " + (i+1) + ": " + progressBars[i]);
    setInterval(increaseVal(progressBars[i]),10);
  }
};

function increaseVal(progressBar){
  console.log("In increaseVal(): " + progressBar.value);
	if(progressBar.value<100){
  	progressBar.value = progressBar.value + 1;
  }
}
Run Code Online (Sandbox Code Playgroud)
<progress class="progress" value="20" max="100"></progress>
<br>
<progress class="progress" value="0" max="100"></progress>
<br>
<progress class="progress" value="30" max="100"></progress>
<br>
<br>
<input type="button" value="Animate" id="animateButton"/>
Run Code Online (Sandbox Code Playgroud)

javascript

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

如何更改VMware Clarity Design System品牌图标大小

我正在使用VMware Clarity Design System UI(https://vmware.github.io/clarity/)并正在运行他们的种子应用程序.我正在尝试用我自己的品牌替换他们的品牌图标,但它的尺寸不同.我注意到该图标似乎是硬编码为36px x 36px.如果我尝试在CSS中设置新的大小,它仍然呈现为36px x 36px.这是硬编码的吗?

LogoSize

vmware user-interface clarity vmware-clarity

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

Angular 2*ng如果没有更新HTML模板

为什么*ngIf没有更新模板?无论isVisible在2秒后变为false,都会显示标题hello.

@Component({
  selector: 'my-app',

  template: `
    <h1 *ngIf="isVisible == true">{{title}}</h1>
  `
})
export class AppComponent {
  title = 'Hello!';
  isVisible = true;

  constructor() {
    setTimeout(function() {
            this.isVisible = false;
            console.log(this.isVisible);
    }, 2000);
  }
}
Run Code Online (Sandbox Code Playgroud)

angular

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

具有绝对定位的工具提示元素被容器裁剪并溢出:自动

我在模态中有一个工具提示。

有没有办法可以避免工具提示被带有overflow它的容器剪掉?

我需要模态对话框来处理内容溢出,所以我无法从中删除overflow: auto

body {
  margin: 0;
}

.container {
  display: flex;
  height: 100vh;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  display: block;
  height: 50%;
  width: 50%;
  background: cyan;
  border: 1px solid;
  overflow: auto;
}

.tooltip {
  position: relative;
  color: red;
  text-decoration: underline;
}

.tooltip::after {
  display: none;
  content: 'Hello';
  position: absolute;
  left: -100%;
  top: -100%;
  height: 20px;
  width: 60px;
}

.tooltip:hover::after {
  display: inline-block;
  background: black;
  color: white;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="modal-dialog">
    <span …
Run Code Online (Sandbox Code Playgroud)

html javascript css flexbox

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

在Clarity 0.9.14中水平调整浏览器大小时重叠文本

视口大小较小时,表单字段会重叠.当空间不足时,有没有办法在下一行捕捉表单字段?

代码片段:

<form class="compact">
          <div class="row">
            <div class="col-xs-6">
              <section class="form-block">
                <div class="form-group">
                  <label for="aForm_1">This is a form field</label>
                  <input type="text" id="aForm_1" placeholder="Enter value here" size="45">
                </div>
              </section>
            </div>
            <div class="col-xs-6">
              <section class="form-block">
                <div class="form-group">
                  <label for="aForm_2">Overlapping Text</label>
                  <input type="text" id="aForm_2" placeholder="Enter value here" size="45">
                </div>
              </section>
            </div>
          </div>
        </form>
Run Code Online (Sandbox Code Playgroud)

这是plunker:https://embed.plnkr.co/ynfi39fIMk1bc8bSBHAp/

重叠的文字

vmware-clarity

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

Angular 2在发出事件时调用函数/方法

我有一个组件,当单击关闭按钮时可以从页面中删除该组件.我已经公开了一个testClose事件,用户可以在组件关闭时注册以完成一些工作.当组件关闭时,如何注册该事件以调用函数?例如,当TestComponent关闭时,我想将closeCounter增加1.这是plnkr:

https://plnkr.co/edit/iGyzIkUQOTCGwaDqr8o0?p=preview

暴露事件的TestComponent:

import {Component, Input, Output, EventEmitter} from 'angular2/core';

@Component({
  selector: 'test',
  template: `
      <div class="box" *ngIf="!_close">
        <button class="close" (click)="close()">x</button>
      </div>
    `,
    styles:[
      `
        .box{
          background: yellow;
          height: 100px;
          width: 100px;
        }
      ` 
    ]
})
export class TestComponent{

  @Input("testClose") _close = false;
  @Output("testCloseChange") _closeChange = new EventEmitter<boolean>(false);

  close(): void{
    this._close = true;
    this._closeChange.emit(true);
  }

  open(): void{
    this._close = false;
    this._closeChange.emit(true);
  }

}
Run Code Online (Sandbox Code Playgroud)

App Component应该注册到TestComponent的close事件来调用某个函数.

import {Component} from 'angular2/core';
import {TestComponent} from './test.component';

@Component({
    selector: "my-app",
    template: ` …
Run Code Online (Sandbox Code Playgroud)

angular

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