小编Nat*_*lia的帖子

通过id获取元素 - Angular2

我有一个代码:

document.getElementById('loginInput').value = '123';
Run Code Online (Sandbox Code Playgroud)

但在编译代码时我收到以下错误:

HTMLElement类型中不存在属性值.

我宣布了一个var : value: string;.

我怎样才能避免这个错误?

谢谢.

javascript typescript angular

39
推荐指数
3
解决办法
11万
查看次数

猫头鹰旋转木马和视差背景

我必须在 owl carousel 中使用 parallax.js 作为背景图像。例如,我想将http://pixelcog.github.io/parallax.js/https://owlcarousel2.github.io/OwlCarousel2/docs/started-welcome.html一起使用, 我该怎么做?笔:https : //codepen.io/naaatasha/pen/gRdoej

<div class="owl-carousel slider">
  <div class="item slide-wrapper parallax-window" data-parallax="scroll" data-image-src="http://trawnik.nazwa.pl/TrawnikProducent2016/wp-content/uploads/slide-strong-1.jpg">
            <div class="container">
                <div class="box">
                    <h2 class="h2 wow fadeIn text-right">co tam</h2>
                    <span class="subtitle wow fadeIn">ihsisdijbvjd</span>
                </div>
            </div>
        </div>
  <div class="item slide-wrapper parallax-window" data-parallax="scroll" data-image-src="http://www.focus.pl/upload/galleries/19/trawa-19061_l.jpg">
            <div class="container">
                <div class="box">
                    <h2 class="h2">lorem ipsum</h2>
                    <span class="subtitle">asdsk jbsjfd</span>
                </div>
            </div>
        </div>
    </div>


.slider {
    position: relative;
    display: table;
}
.box {
    display: table-cell;
    vertical-align: middle;
    width: 1%;
}
.slide-wrapper {
    height: 800px; …
Run Code Online (Sandbox Code Playgroud)

parallax owl-carousel-2

5
推荐指数
0
解决办法
3036
查看次数

如何将外部库包含到单元测试中:: Angular2-CLI

我正在为我的项目编写测试用例。但不幸的是,在通过键入开始测试之后ng test,我收到以下错误:

Error: Error in :0:0 caused by: Plotly is
ReferenceError: Plotly is not defined
Run Code Online (Sandbox Code Playgroud)

Plotly是一个外部图表库。我试图在test文件中声明它:

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MaterialModule } from '@angular/material';
import { WatchlistComponent } from './watchlist.component';
declare let Plotly: any;

describe('SystemComponent', () => {
  let component: WatchlistComponent;
  let fixture: ComponentFixture<WatchlistComponent>;
  let element;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing jasmine karma-jasmine angular

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

在选择选项中使用@click-Vue.js 2

我想在选择选项中使用@click。

到目前为止,我有:

<button @click="sortBy('name')">sort by name</button>
<button @click="sortBy('price')">sort by price</button>
Run Code Online (Sandbox Code Playgroud)

并且可以正常工作,但是当我将其插入选项标签时,它停止工作了。

<select name="sortBy" id="sortBy">
  <option value="sort">sort By</option>
  <option @click="sortBy('name')">name</option>
  <option @click="sortBy('price')">price</option>
</select>
Run Code Online (Sandbox Code Playgroud)

我的功能:

sortBy(sortKey) {
    this.items.sort((a, b) =>
    (typeof a[sortKey] === 'string' || typeof b[sortKey] === 'string') ? 
    a[sortKey].localeCompare(b[sortKey]) : a[sortKey] - b[sortKey]);
}
Run Code Online (Sandbox Code Playgroud)

javascript vuejs2

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