如何在 AngularJS 中打开/关闭 $log.debug [英] How to turn on/off $log.debug in AngularJS
本文介绍了如何在 AngularJS 中打开/关闭 $log.debug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 $log.debug("Foo").怎么可能关掉.我在任何地方都找不到样本.我认为它需要在配置中设置,但我似乎也无法让它工作.
I'm trying to use $log.debug("Foo"). How can it be turned on off. I can't find a sample anywhere. I think it need to be set in the config, but I cant seem to get that to work either.
开关在哪里设置?
推荐答案
$logProvider.debugEnabled(true)
$logProvider.debugEnabled(true)
这仅在 AngularJs 1.1.2 或更高版本中可用.
This is only available in AngularJs 1.1.2 or later.
https://github.com/angular/angular.js/pull/1625
这是设置的示例.
var app = angular.module('plunker', []);
app.config(function($logProvider){
$logProvider.debugEnabled(true);
});
app.controller('MainCtrl', function($scope, $log ) {
$scope.name = 'World';
$scope.model = {value: "test"};
$log.debug('TEST Log');
});
http://plnkr.co/edit/HZCAoS?p=preview
默认开启.
这篇关于如何在 AngularJS 中打开/关闭 $log.debug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文