0

Hello everyone I have this problem related to Angular.

inside my skills.component.ts .

@Input() testfield ="";

inside skills.component.html

     style="padding: 0 10%"
     class="row align-items-center">
  <p id="skill"
     class="col-2"
     style="font-family: Mulish-Bold, serif; font-size: 1.2rem; text-align: end;"
  >
    {{testfield}}
  </p>
  <p class="col-7" id="bar">

    <ngb-progressbar
      type="success"
      [value]="50">
    </ngb-progressbar>
  </p>
</div>

and inside the component that uses this app-skill-bar .

  <app-section-title color="#84142D" icon="bi bi-star-fill" title="Skills"></app-section-title>
  <app-skill-bar testfield="Android"></app-skill-bar>
</div>

the problem is that angular can't take "Android" as value for testfield. also, it doesn't desplay Android. enter image description here

5
  • Can you share your code or share a link of stackblitz that can reproduce the same issue? Commented Aug 14, 2022 at 9:51
  • okay this is the github link github.com/muath-nassar/cv-angular.git Commented Aug 14, 2022 at 10:18
  • 1
    Interesting issue ngOnChanges showing that value updated but input variable not displaying the value in html. Looking into it! Commented Aug 14, 2022 at 11:12
  • yes 👍 this is the key point. thnx for your time. Commented Aug 14, 2022 at 11:18
  • @SparrowVic has given the correct answer. Commented Aug 14, 2022 at 11:23

1 Answer 1

1

I checked your project. The input works correctly. The problem is that you create in app.module.ts two independent components trees. The first time a component is loaded, the value "Android" exists, but then the component is quickly reloaded with no value passed. You can analyze this by putting the debugger in ngOnInit method in your SkillBarComponent. All in all, you should remove SkillBarComponent from the bootstrap array. enter image description here

Since you added SkillBarComponent in bootstrap array, it will be considered as root component and You are passing an input in the root component, which will not work.

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

1 Comment

Yes, you are right, 😊 , You are very intelligent.

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.