locked
why my view is not showing? RRS feed

  • Question

  • User2108892867 posted

    Hello everyone, I scratched my  head wondering why this simple test doesn't work.

    http://jsfiddle.net/U3pVM/60623/

    All I want is to show some text when people.length == 0 but it doesn't show up. If I take the ng-show out, it displays 0.

    Any idea why? 

    Thanks

    Thursday, November 1, 2018 4:04 AM

Answers

  • User2103319870 posted

    All I want is to show some text when people.length == 0 but it doesn't show up. If I take the ng-show out, it displays 0.

    Any idea why? 

    we dont need to use {{}} with ng-show. Try with below code

    <div ng-app>
      <h2>Todo</h2>
      <div ng-controller="TodoCtrl">
       
        <div ng-show="people.length == 0">
        {{people.length}}
        </div>
       
      </div>
    </div>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 1, 2018 9:05 PM
  • User61956409 posted

    Hi asplearning,

    <div ng-show="{{people.length == 0}}">

    All I want is to show some text when people.length == 0

    As A2H mentioned, please remove double braces {{ }} from the ng-show directive. For detailed usage of the ng-show directive, please check documentation: https://docs.angularjs.org/api/ng/directive/ngShow 

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 2, 2018 2:14 AM

All replies

  • User2103319870 posted

    All I want is to show some text when people.length == 0 but it doesn't show up. If I take the ng-show out, it displays 0.

    Any idea why? 

    we dont need to use {{}} with ng-show. Try with below code

    <div ng-app>
      <h2>Todo</h2>
      <div ng-controller="TodoCtrl">
       
        <div ng-show="people.length == 0">
        {{people.length}}
        </div>
       
      </div>
    </div>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 1, 2018 9:05 PM
  • User61956409 posted

    Hi asplearning,

    <div ng-show="{{people.length == 0}}">

    All I want is to show some text when people.length == 0

    As A2H mentioned, please remove double braces {{ }} from the ng-show directive. For detailed usage of the ng-show directive, please check documentation: https://docs.angularjs.org/api/ng/directive/ngShow 

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 2, 2018 2:14 AM