3

(Sorry for my english, it's not my first language...)

I have some issue with some input paramaters I inject in my component when I call it with its template.

slider-multiple.component.ts :

import { Component, Input } from '@angular/core';

@Component({
  selector: 'slider-multiple',
  templateUrl: './slider-multiple.component.html'
 })
export class SliderMultipleComponent  {
   @Input() public modifiable: boolean;
 }

slider-multiple.component.html :

<button *ngIf="modifiable">Slider Button</button>

Call of the directive (for instance on app.component.html) :

<slider-multiple modifiable="activation"></slider-multiple>

With activation defined on app.component.ts :

export class AppComponent  {
   public activation : boolean = false ;

   public activate(){
     this.activation = !this.activation;
   }
 }

The button I defined on the html template of my component should be visible (through the *ngIf) only when the activation parameter of the directive is at true.

Does anyone knows why it don't work as expected ?

A Stackblitz to help .

Thanks in advance !

1
  • missing the [] around modifiable. Commented Apr 12, 2018 at 15:04

1 Answer 1

11

Change <slider-multiple modifiable="activation"></slider-multiple>

To <slider-multiple [modifiable]="activation"></slider-multiple>

modifiable="activation" binds to the string with the value ofactivation.

[modifiable]="activation" binds to the component property with the name of activation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.