javascript - Using an if statement according to the size of a list in angular js -


Is it possible and what type of effort I am trying to make:

< P> example 2.html

  & lt; Head & gt; & Lt; Title & gt; Test2 & lt; / Title & gt; & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H2 & gt; Section Two & lt; / H2 & gt; & Lt; Div ng-app = "" ng-controller = "module two controller" & gt; & Lt; P & gt; & Lt; Input type = "text" ng-model = "test" & gt; & Lt; / P & gt; & Lt; Ul & gt; & Lt; Li ng-repeat = "filter = in x = (country filter: test)" & gt; {{X.country}} & lt; / Li & gt; & Lt; / Ul & gt; & Lt; P & gt; Items in the list: {{filtered.length}} & lt; / P & gt; & Lt; / Div & gt; & Lt; Script src = "mod2.js" & gt; & Lt; / Script & gt; & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

mod2.js

  function ModuleTwoController ($ scope) {$ scope.countries = [country: 'Argentina'}, {country: 'USA 'Country:' Brazil '}, {Country:' Hong Kong '}, {Country:' UK '}, {Country:' Turkey '}, {Country:' Rwanda '}, {Country:' Federal State Microna}} , {Country: 'India'}, {country: 'South Africa'}]; }  

Now when I type in any one country, if I type in someone's name, then I am returned. I want my statement if 'list' Size = 1 'then the country flag will display. If the size of the list is not displayed> 1 is a way to do this in html / js / css and is the function good in angular?

"post-text" itemprop = "text">

Sure, just check the length of the property:

   

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -