如何在ng-grid中访问全局Javascript变量?
我有一个全局变量var ShowApprovalLog = "True",我想在ng-grid cellTemplate中访问它。
{
field: 'Urgent',
width:'60px',
displayName: 'Urgent',
enableSorting: false,
cellTemplate:
'<div class="ngSelectionCell">{{row.entity.Urgent}}
<span ng-if=\"ShowApprovalLog ==\'True\' \">
<img src=\"../Images/Urgent.png\" alt=\"Image\"/></span></div>'
},发布于 2015-10-14 22:17:54
为什么不在模块的run部分把它放到$rootScope中呢?
angular.module('myModule', []).
config(function(injectables) { // provider-injector
// This is an example of config block.
// You can have as many of these as you want.
// You can only inject Providers (not instances)
// into config blocks.
}).
run(function(injectables) { // instance-injector
// This is an example of a run block.
// You can have as many of these as you want.
// You can only inject instances (not Providers)
// into run blocks
$rootScope.ShowApprovalLog = "true"
});您可以使用{{ShowApprovalLog}}从任何视图访问该值
https://stackoverflow.com/questions/33127716
复制相似问题