0

I'm trying to get the right value for the skill.team[variable here].name where Angular gets all the team name from the skill

Here's my code:

HTML

<select [(ngModel)]="skill.teams[1].name" name="teamName" id="teamName" class="form-control">
                    <option *ngFor="let skill of skills" [value]="skill.teams[1].name">{{ skill.teams[1].name }}</option>
                  </select> 

ARRAY

skill = {
  _id:'',
  name:'',
  teams:[{name:'team1'},{name:'team2'}]
} 
1
  • 2
    It's Angular. There's no such thing as AngularJS 4. Commented Sep 13, 2017 at 19:06

2 Answers 2

2

I believe this is what you're looking for; you should be iterating over the skill.teams array with your *ngFor. This also changes the model to be skill.name, however, which may or may not be exactly what you're looking for.

<select [(ngModel)]="skill.name" name="teamName" id="teamName" class="form-control">
        <option *ngFor="let team of skill.teams" [value]="team.name">{{team.name}}</option>
</select>  
Sign up to request clarification or add additional context in comments.

Comments

0

Do a console log for skill console.log(skill); the console output will give you the structure of your iterables.

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.