Questions tagged «ng-show»

7
AngularJS:ng-show / ng-hide不适用于`{{}}`插值
我试图使用AngularJS提供的ng-show和ng-hide函数显示/隐藏一些HTML 。 根据文档,这些功能的各自用法如下: ngHide – {表达式}-如果表达式为true,则分别显示或隐藏该元素。ngShow – {表达式}-如果表达式为真,则分别显示或隐藏该元素。 这适用于以下用例: <p ng-hide="true">I'm hidden</p> <p ng-show="true">I'm shown</p> 但是,如果我们使用对象中的参数作为表达式,则ng-hide和ng-show被赋予正确的true/ false值,但这些值不会被视为布尔值,因此始终返回false: 资源 <p ng-hide="{{foo.bar}}">I could be shown, or I could be hidden</p> <p ng-show="{{foo.bar}}">I could be shown, or I could be hidden</p> 结果 <p ng-hide="true">I should be hidden but I'm actually shown</p> <p ng-show="true">I …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.