想要显示“无数据”当ng-options中的角度js功能中没有返回数据时 [英] Want to display "no data" when there is no data returned in angular js fuction in the ng-options

查看:68
本文介绍了想要显示“无数据”当ng-options中的角度js功能中没有返回数据时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的要求是

如果在选择内部ng选项中没有从js函数返回的数据,我想显示一条消息无数据。我正在尝试如下



我尝试过:



Hi My Requirement is
I want to display a message saying "No Data" when there is no data returned from js function in the select inside ng options. I am trying as below

What I have tried:

<td>
             Accessories
         </td>
         <td>
             <span style="display:none;"><input type="text" name="Subscriptions[@Model.SubscriptionIndex].SelectedAccessories" ng-model="fields.Accessories" /></span>
             <select multiple name="AccessoriesTmp"
                     ng-options="AvailableChildProducts('Accessories').Length>=0 ? extra.Id as extra.Name for extra in AvailableChildProducts('Accessories'):'No data'"
                     ng-model="fields.Accessories"></select>
         </td>

推荐答案

试试这个



try this

<div ng-app="myApp" ng-controller="myCtrl">
       <select  >
           <option ng-repeat="x in names">{{x}}</option>
       </select>

   </div>

   <script>
       var app = angular.module('myApp', []);
       app.controller('myCtrl', function (


scope){


scope.names = []; // [ Emil,Tobias,Linus];
if(
scope.names =[];// ["Emil", "Tobias", "Linus"]; if (


这篇关于想要显示“无数据”当ng-options中的角度js功能中没有返回数据时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆