javascript - ng-if check if array is empty -


the api working returns if there no items in array

items: [] 

if there items in array returns like

items: [   {     name: 'bla'   } ] 

in template believe need use ng-if either show/hide element based on whether there data in there or not.

<p ng-if="post.capabilities.items"><strong>topics</strong>: <span ng-repeat="topic in post.capabilities.items">{{topic.name}}</p> 

however totally off base first time working in angular, , there may better way trying do.

post.capabilities.items still defined because it's empty array, if check post.capabilities.items.length should work fine because 0 falsy.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -