2

I've got this code:

AngularJS:

$scope.languages = [
  { language: "English", i18n: "en" },
  { language: "Espanol", i18n: "es" },
  { language: "Polski", i18n: "pl" },
  { language: "Portugues", i18n: "pt" },
  { language: "Svenska", i18n: "se" },
];

HTML:

<li ng-repeat="lang in languages" id="langRow_{{lang.i18n}}">
  <a href="#" id="lang_{{lang.i18n}}" ng-click="changeLang(lang.i18n);"><i class="flag-icon flag-icon-{{lang.i18n}} mr-sm"></i>{{lang.language}}</a>
</li>

and I want to hide an element from loop, for example:

$("#langRow_es").hide();

It doesn't work. How to solve this?

1
  • 1
    Why not use ngShow or ngHide? Commented Jan 4, 2016 at 15:49

2 Answers 2

6

1) If you want to use Angular, FORGET JQUERY.

2) USE ANGULAR.

Try this :

<li ng-repeat="lang in languages" ng-hide="lang.i18n=='es'" >
Sign up to request clarification or add additional context in comments.

2 Comments

Well beginner, remember the rule number one : FORGET JQUERY :) And please validate my answer if you believe it's correct. Cheers!
see also: stackoverflow.com/questions/13151725/… and stackoverflow.com/questions/14994391/… the latter is imho a good source even though it is closed.
0

No Need Of Using Id Operation Here. But U can use "ng-if" also if we do not want to render the element completely inorder to hide. So we will see all languages other than english.

<li ng-repeat="lang in languages" ng-if="lang.i18n !=='es'"> <a href="#" id="lang_{{lang.i18n}}" ng-click="changeLang(lang.i18n);"><i class="flag-icon flag-icon-{{lang.i18n}} mr-sm"></i>{{lang.language}}</a> </li>

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.