我在Rails中有条件:
if @user.permissions.include?('show_reports')
我需要在角页面检查上述条件。 如何用ng-if条件写?
例如,有一个下拉类
.dropdown
%h1 This is example
在所有其他页面中,他们写道:
.dropdown{ng-if => ...}
但无法写上述条件。请帮忙。
答案 0 :(得分:1)
<script>
var myapp = angular.module('myapp', []);
myapp.controller('Controller', Controller);
function Controller(){
var scope = this;
scope.has_reports = <%= @user.permissions.include?('show_reports') %>;
}
</script>
然后使用它像&#39; ng-if&#39; =&GT; &#34; ctrl.has_reports&#34;,
这里ctrl是ng-controller