小编mic*_*ael的帖子

ng-if only 第一个指令与自关闭标签一起使用

我是角度新手,所以这可能不是最好的方法。随着我了解更多,我可能会重做大部分已经做过的事情。

我正在使用 url 路由,ngRoute它工作得很好。在其中一个页面中,我有许多 ng-include 模板 - 再次,一切都很好。

在其中一个ng-include模板中,我使用两个directives来显示模板。

<provider-search providers="practiceData.providers" states="ref.states" specialties="ref.specialties" status="updateSearchStatus" ng-show="searchStatus == 1"/>
<search-list status="updateSearchStatus" addp="addProvider" providers="searchResults" ng-if="searchStatus == 2" />
Run Code Online (Sandbox Code Playgroud)

每个指令都使用独立的作用域和控制器。问题是只有第一个指令有效。如果我切换顺序,则第二个指令(现在如果是第一个位置)将起作用。简而言之,只有首先列出的指令才有效。

任何帮助表示赞赏。

directive angularjs angularjs-directive angular-ng-if

1
推荐指数
1
解决办法
292
查看次数