如何打开在AngularJS /关闭$ log.debug [英] How to turn on/off $log.debug in AngularJS

查看:794
本文介绍了如何打开在AngularJS /关闭$ log.debug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用$ log.debug(富)。它如何可以打开关闭。我找不到任何地方的样本。我认为它需要在配置中设置的,但我不能似乎得到这工作的。

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.

哪里一组ON和OFF开关?

Where does one set the on and off switch?

推荐答案

$ logProvider.debugEnabled(真)

$logProvider.debugEnabled(true)

这是只有在AngularJs 1.1.2或更高版本。可用

This is only available in AngularJs 1.1.2 or later.

<一个href=\"https://github.com/angular/angular.js/pull/1625\">https://github.com/angular/angular.js/pull/1625

下面是它被设置的一个例子。

Here is an example of it being set.

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=$p$pview

在默认情况下它是。

这篇关于如何打开在AngularJS /关闭$ log.debug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆