我创建了滑块的输入属性 @Input(' inputSlider')inputSlider:SliderComponent; 我想只改变每个不同组件中的imageurls数组(属性) 它可能吗?如果是的话,我应该怎么做
import { AboutComponent } from './../about/about.component';
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-slider',
templateUrl: './slider.component.html',
styleUrls: ['./slider.component.css']
})
export class SliderComponent {
@Input('inputSlider') inputSlider: SliderComponent;
height: string = '400px';
minHeight: string;
arrowSize: string = '30px';
showArrows: boolean = false;
disableSwiping: boolean = false;
autoPlay: boolean = true;
autoPlayInterval: number = 3333;
stopAutoPlayOnSlide: boolean = true;
debug: boolean = false;
backgroundSize: string = 'cover';
backgroundPosition: string = 'center center';
backgroundRepeat: string = 'no-repeat';
showDots: boolean = false;
width: string = '100%';
reloded: boolean = true;
imageUrls = [
'https://cdn.vox-cdn.com/uploads/chorus_image/image/56748793/dbohn_170625_1801_0018.0.0.jpg',
'https://cdn.vox-cdn.com/uploads/chorus_asset/file/9278671/jbareham_170917_2000_0124.jpg',
'https://cdn.vox-cdn.com/uploads/chorus_image/image/56789263/akrales_170919_1976_0104.0.jpg',
'https://cdn.vox-cdn.com/uploads/chorus_image/image/56674755/mr_pb_is_the_best.0.jpg'
];
}

<slideshow #slideshow [imageUrls]="imageUrls" [height]="height" [minHeight]="minHeight" [arrowSize]="arrowSize" [showArrows]="showArrows"
[disableSwiping]="disableSwiping" [autoPlay]="autoPlay" [stopAutoPlayOnSlide]="stopAutoPlayOnSlide" [debug]="debug" [backgroundSize]="backgroundSize"
[backgroundPosition]="backgroundPosition" [backgroundRepeat]="backgroundRepeat" [showDots]="showDots">
</slideshow>
&#13;
答案 0 :(得分:0)
我收到了你的问题,但你的代码中存在一些不匹配的内容,例如你创建的组件是&#34; app-slider&#34;您正在使用的模板和CSS&#34; slider.component。*&#34;并在你的HTML代码中 所以无法完全得到它。 但是,无论你想做什么,非常简单的输入和输出是这种行为的主要特征。 如果您能为我提供适当的代码和结构,我可以为您提供更多帮助。作为参考,您可以查看以下链接: https://www.concretepage.com/angular-2/angular-2-input-and-output-example https://angular.io/guide/component-interaction
由于