用 Jade 处理 ng-show

Deal with ng-show with Jade

我正在尝试动态显示和隐藏一些用 Jade 编写的 <div>。正如 w3school 所说,这似乎很容易,但我现在陷入困境以使其正常工作。

我要制作一个带有侧边栏的 Web 应用程序。对于它的每个索引,我想显示和隐藏 html 的片段,在 <div> 标签中给出,具体取决于用户将点击哪个。

下面的代码显示了四个 <div> 标签(test1、test2、test3、test4),我想根据我填写的一些变量(test1Visible、test2Visible、test3Visible、test4Visible)来显示或隐藏它们控制器。

  body(ng-app='myApp' ng-controller='myCtrl')
  //...
  #test1(ng-show='test1Visible')
    include test.jade

  #test2(ng-show='test2Visible')
    include test.jade

  #test3(ng-show='test3Visible')
    include test.jade

  #test4(ng-show='test4Visible')
    include test.jade
  //...

默认显示 none 个 div,我想知道使用 test#Visible 变量的策略是否正确。

怎么了?

知道了!

根本没想到ng-controller='myCtrl'被声明了不止一次。那导致了我的问题。