首页 > 代码库 > [AngularJS] New in Angular 1.3 - Performance Boost with debugInfoEnabled
[AngularJS] New in Angular 1.3 - Performance Boost with debugInfoEnabled
By default, Angular provides a lot of debug information on the DOM that‘s only necessary for tools like Protractor and Batarang. Angular 1.3 allows you to turn off the debug information to give your app a simple performance boost.
See: https://docs.angularjs.org/api/ng/provider/$compileProvider
More: https://docs.angularjs.org/guide/production#disabling-debug-data
<!DOCTYPE html><html ng-app="app"><head> <title></title> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"> <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.3/angular.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.11/angular-ui-router.js"></script> <script src="app.js"></script></head><body> <script type="text/ng-template" id="templates/home.html"> <note message="Hello"></note> </script> <ui-view></ui-view></body></html>
angular.module("app", ["ui.router"]) .config(function config($stateProvider, $compileProvider) { $stateProvider.state("home", { url: "", templateUrl: "templates/home.html" }) $compileProvider.debugInfoEnabled(false); }) .directive("note", function note() { return { template: "<div>{{ note.message }} {{ note.person }}</div>", controller: "NoteController as note", bindToController: true, scope: { message: "@" } } }) .controller("NoteController", function NoteController() { var note = this; note.person = "John"; })
Without debug info:
If you want open the debug info again:
in console:
angular.reloadWithDebugInfo();
[AngularJS] New in Angular 1.3 - Performance Boost with debugInfoEnabled
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。