Javascript 检查是否有任何角度输入有输入

Javascript 检查是否有任何角度输入有输入,javascript,html,angularjs,Javascript,Html,Angularjs,所以我想看看一系列输入是否有数据,如果有,在别处输出。我已将ng模型应用于具有这些输入的div,但没有得到我想要的结果 我的输入代码: <div class="benefits" ng-model="benefits"> <input type="text" class="form-control" ng-model="benefit1" placeholder="benefit 1" style="font-size:18px; margin-bo

所以我想看看一系列输入是否有数据,如果有,在别处输出。我已将ng模型应用于具有这些输入的div,但没有得到我想要的结果

我的输入代码:

<div class="benefits" ng-model="benefits">          
    <input type="text" class="form-control" ng-model="benefit1" placeholder="benefit 1" style="font-size:18px; margin-bottom: 25px;">
    <input type="text" class="form-control" ng-model="benefit2" placeholder="benefit 2" style="font-size:18px; margin-bottom: 25px;">
    <input type="text" class="form-control" ng-model="benefit3" placeholder="benefit 3" style="font-size:18px; margin-bottom: 25px;">       
    <input type="text" class="form-control" ng-model="benefit4" placeholder="benefit 4" style="font-size:18px; margin-bottom: 25px;">
    <input type="text" class="form-control" ng-model="benefit5" placeholder="benefit 5" style="font-size:18px; margin-bottom: 25px;">   
</div>  

和我的输出(工作不正常:

<ul class="outputText" ng-show="benefits != null">Perceived benefits:
    <li>{{ (benefit1 != null) ? benefit1 : '[describe benefit 1]' }}</li>
    <li>{{ (benefit2 != null) ? benefit2 : '[describe benefit 2]' }}</li>
    <li>{{ (benefit3 != null) ? benefit3 : '[describe benefit 3]' }}</li>
    <li>{{ (benefit4 != null) ? benefit4 : '[describe benefit 4]' }}</li>
    <li>{{ (benefit5 != null) ? benefit5 : '[describe benefit 5]' }}</li>
</ul>
感知到的好处:
  • {(福利1!=null)?福利1:“[描述福利1]”}
  • {{(福利2!=null)?福利2:'[描述福利2]'}
  • {{(福利3!=null)?福利3:'[描述福利3]'}
  • {(福利4!=null)?福利4:“[描述福利4]”}
  • {{(福利5!=null)?福利5:'[描述福利5]'}
  • 如果在div上使用ng模型不是一种可行的方法,那么我如何设置从1到5的收益范围,以使输出简单化

    我确信这是一些简单的东西,我只是没有看到

    非常感谢。

    尝试使用
    并使用命名表单的
    $dirty
    属性

    angular.module(“MyApp”,[])
    .controller(“MyController”,function(){});
    
    感知到的好处:
    
  • {{(收益1)?收益1:'[描述收益1]'}
  • {{(收益2)?收益2:'[描述收益2]'}
  • {{(收益3)?收益3:'[描述收益3]'}
  • {(收益4)?收益4:'[描述收益4]'}
  • {{(收益5)?收益5:'[描述收益5]'}
  • 尝试使用
    并使用命名表单的
    $dirty
    属性

    angular.module(“MyApp”,[])
    .controller(“MyController”,function(){});
    
    感知到的好处:
    
  • {{(收益1)?收益1:'[描述收益1]'}
  • {{(收益2)?收益2:'[描述收益2]'}
  • {{(收益3)?收益3:'[描述收益3]'}
  • {(收益4)?收益4:'[描述收益4]'}
  • {{(收益5)?收益5:'[描述收益5]'}

  • 一个
    会有一个
    ng模型,这是没有意义的。一个div没有输入/输出。它们没有值。因为这些输入在它们为空时不等于
    null
    会有一个
    ng模型,这是没有意义的。它们没有值。因为当这些输入为空时,它们不等于
    null
    。。这在这里起作用,但在我的代码中无法起作用。同一代码中的其他角度片段也起作用。这可能是因为它是一个带有表单的表单吗?@标记是否复制并粘贴了此代码?确保使用了正确的控制器和模块名称。在我的代码中,它们是
    MyController
    MyApp
    分别。如果您使用不同的名称,可能需要在HTML或JS中更改它们。您的调试工具中是否有任何控制台错误?这在这里可以工作,但在我的代码中无法工作。同一代码中的其他角度片段也可以工作。这可能是因为它是带有表单的表单吗@标记是否复制并粘贴了此代码?请确保使用了正确的控制器和模块名称。在我的代码中,它们分别是
    MyController
    MyApp
    。如果使用不同的名称,可能需要在HTML或JS中更改它们。调试工具中是否存在任何控制台错误?